How to Build a GCC Cross-Compiler (preshing.com)
libwiringPi.so:undefined reference to ‘fcntl@GLIBC_2.28‘_wiringpi undefined reference to-CSDN博客
gcc --version
ld -v
ldd --version
uname -a
源码包 | 版本查看命令 | 版本 |
---|---|---|
Binutils | ld -v | |
gcc | gcc --version | |
kernel | uname -a | |
glibc | ldd --version | |
mpfr | find /. -name libmpfr.* | |
gmp | find /. -name libgmp.* | |
mpc | find /. -name libmpc.* | |
isl | gcc --version | –without-isl |
cloog | gcc --version | –without-cloog |
without-isl 和 without-cloog 不用下载 isl、cloog
以下下载版本,可以复制路径选择目标服务器对应的版本下载
$ wget http://ftpmirror.gnu.org/binutils/binutils-2.24.tar.gz
$ wget http://ftpmirror.gnu.org/gcc/gcc-4.9.2/gcc-4.9.2.tar.gz
$ wget https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.17.2.tar.xz
$ wget http://ftpmirror.gnu.org/glibc/glibc-2.20.tar.xz
$ wget http://ftpmirror.gnu.org/mpfr/mpfr-3.1.2.tar.xz
$ wget http://ftpmirror.gnu.org/gmp/gmp-6.0.0a.tar.xz
$ wget http://ftpmirror.gnu.org/mpc/mpc-1.0.2.tar.gz
$ wget https://gcc.gnu.org/pub/gcc/infrastructure/isl-0.12.2.tar.bz2
$ wget https://gcc.gnu.org/pub/gcc/infrastructure/cloog-0.18.1.tar.gz
$ for f in *.tar*; do tar xf $f; done
$ cd gcc-4.9.2
$ ln -s ../mpfr-3.1.2 mpfr
$ ln -s ../gmp-6.0.0 gmp
$ ln -s ../mpc-1.0.2 mpc
$ ln -s ../isl-0.12.2 isl
$ ln -s ../cloog-0.18.1 cloog
$ cd ..
mkdir -p /opt/cross
vim /etc/profile
添加:export PATH=/opt/cross/bin:$PATH
$ mkdir build-binutils
$ cd build-binutils
$ ../binutils-2.24/configure --prefix=/opt/cross --target=aarch64-linux --disable-multilib
$ make -j4
$ make install
$ cd ..
注释:可能问题
(1)makeinfo: command not found
yum install texinfo
$ cd linux-3.17.2
$ make ARCH=arm64 INSTALL_HDR_PATH=/opt/cross/aarch64-linux headers_install
$ cd ..
$ mkdir -p build-gcc
$ cd build-gcc
$ ../gcc-4.9.2/configure --prefix=/opt/cross --target=aarch64-linux --enable-languages=c,c++ --disable-multilib
$ make -j4 all-gcc
$ make install-gcc
$ cd ..
$ mkdir -p build-glibc
$ cd build-glibc
$ ../glibc-2.20/configure --prefix=/opt/cross/aarch64-linux --build=$MACHTYPE --host=aarch64-linux --target=aarch64-linux --with-headers=/opt/cross/aarch64-linux/include --disable-multilib libc_cv_forced_unwind=yes
$ make install-bootstrap-headers=yes install-headers
$ make -j4 csu/subdir_lib
$ install csu/crt1.o csu/crti.o csu/crtn.o /opt/cross/aarch64-linux/lib
$ aarch64-linux-gcc -nostdlib -nostartfiles -shared -x c /dev/null -o /opt/cross/aarch64-linux/lib/libc.so
$ touch /opt/cross/aarch64-linux/include/gnu/stubs.h
$ cd ..
因为gcc 和 glibc互相依赖
cd build-gcc
make -j4 all-target-libgcc
make install-target-libgcc
cd ..
因为gcc 和 glibc互相依赖
cd build-glibc
make -j4
make install
cd ..
cd build-gcc
make -j4
make install
cd ..
option(ARM-BUTTON "arm" ON)
if (ARM-BUTTON)
# #交叉编译设置
set(CMAKE_SYSTEM_NAME Linux) #设置目标系统名字
set(CMAKE_SYSTEM_PROCESSOR aarch64) #设置目标处理器架构
# # 指定编译器的 sysroot 路径
set(TOOLCHAIN_DIR /opt/cross)
# # 指定交叉编译器 arm-gcc 和 arm-g++
set(CMAKE_C_COMPILER ${TOOLCHAIN_DIR}/bin/aarch64-linux-gcc)
endif(ARM-BUTTON)
(1)…/…/…/…/gcc-4.9.2/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc:157:10: 致命错误:sys/ustat.h:没有那个文件或目录
修改 libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc
文件:
Linux下gcc编译报错:fatal error: sys/ustat.h: No such file or directory 解决办法-CSDN博客
(2)错误:‘PATH_MAX’ undeclared
#include
欲速则不达!!!!!!!!