环境:ubuntu22.04为刚刚安装,未安装gcc等包
vi ~/.bashrc输入
export PATH=$PATH:/opt/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin
保存,reboot
安装:
- sudo apt install cmake
- sudo apt install gawk
- sudo apt install bison
- mkdir build
- cd build
-
- ../configure --prefix=${PWD}/install \
- --build=arm-linux-gnu \
- --host=arm-linux-gnu \
- --target=arm-linux-gnu \
- CC=arm-linux-gnueabihf-gcc \
- CXX=arm-linux-gnueabihf-g++ \
- CPP=arm-linux-gnueabihf-cpp \
- --disable-multilib libc_cv_forced_unwind=yes
-
- make
- make install
- ./configure --prefix=${PWD}/install/ --host=arm-linux --disable-assembly CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++
-
- make
- make install
- ./configure --prefix=${PWD}/install --host=arm-linux CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++ --with-gmp=/opt/gmp-6.1.0/install
-
- make
- make install
- ./configure --prefix=${PWD}/install --host=arm-linux CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++ --with-gmp=/opt/gmp-6.1.0/install --with-mpfr=/opt/mpfr-3.1.4/install
-
- make
- make install
将/opt/gmp-6.1.0/install/lib目录下所有库文件拷贝到gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/arm-linux-gnueabihf/libc/usr/lib/,
然后执行
- ./configure --prefix=${PWD}/install --host=arm-linux CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++ --with-gmp-prefix=/opt/gmp-6.1.0/install
-
- make
- make install
删除cc
- cd /usr/bin
- sudo rm cc
- sudo ln -s /opt/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc cc
- reboot
然后安装一些库,要不然编译不过
sudo apt-get install lsb-core lib32stdc++6
然后执行
- ./configure --prefix=${PWD}/build \
- --with-gmp=/opt/gmp-6.1.0/install \
- --with-mpfr=/opt/mpfr-3.1.4/install \
- --with-mpc=/opt/mpc-1.0.3/install \
- --with-isl=/opt/isl-0.18/install \
- CC=arm-linux-gnueabihf-gcc \
- CXX=arm-linux-gnueabihf-g++ \
- CPP=arm-linux-gnueabihf-cpp \
- --host=arm-linux-gnueabihf \
- --target=arm-linux-gnueabihf \
- --with-newlib \
- --without-headers \
- --enable-initfini-array \
- --disable-nls \
- --disable-shared \
- --disable-multilib \
- --disable-decimal-float \
- --disable-threads \
- --disable-libatomic \
- --disable-libgomp \
- --disable-libquadmath \
- --disable-libssp \
- --disable-libvtv \
- --disable-libstdcxx \
- --enable-checking=release \
- --enable-languages=c,c++
-
- make -j8 all-gcc
- make install-gcc
问题:Oops, mp_limb_t is 64 bits, but the assembler code
解决:https://gist.github.com/cwoac/5844398
I realised the first failure was because it tried to build the 64 bit code on a 32 bit platform.
The attached gist is the failure when running with --32-bit.
This can be worked around by adding --disable-assembly to the configure call
同时:
sudo apt-get install m4
gcc-9.5源码根目录/contrib/download_prerequisites 里面地有需要依赖的库源码版本,可以直接执行./contrib/download_prerequisites下载