我想从 OS X 10.7 + Eclipse 构建系统为 Linux 服务器编译二进制文件。这意味着一个 GCC 交叉编译器。我从本机 4.7.1 开始,为主机 4.7.1 拍摄。
大多数在线说明都特定于嵌入式开发。我想使用 libstdc++-v3 和 glibc,这让它有点不同。
什么成功:
安装包
port install gcc47 export CC=gcc-mp-47 export LD=ld-mp-47 export CXX=g++-mp-47 export CPP=cpp-mp-47 port install gmake ln /opt/local/bin/gmake /opt/local/bin/make port install gsed ln /opt/local/bin/gsed /opt/local/bin/sed port install gawk port install autoconf port install msgfmt
制作并安装 binutils-2.22
make all-gcc
和make install-gcc
使用了以下配置:
$ ../gcc/configure --enable-languages=c,c++,objc,obj-c++ --with-gmp=/opt/local --with-mpfr=/opt/local --with-mpc=/opt /local --prefix=/usr/local/cross/linux --target=x86_64-pc-linux-gnu --disable-nls
将构建环境指向交叉编译器
export CC=/usr/local/cross/linux/bin/x86_64-pc-linux-gnu-gcc export LD=/usr/local/cross/linux/bin/x86_64-pc-linux-gnu-ld export AR=/usr/local/cross/linux/bin/x86_64-pc-linux-gnu-ar export CXX=/usr/local/cross/linux/bin/x86_64-pc-linux-gnu-g++ export CPP=/usr/local/cross/linux/bin/x86_64-pc-linux-gnu-cpp
使用配置构建 glibc-2.16
../glibc/configure --host=x86_64-pc-linux-gnu --build=x86_64-apple-darwin11 --prefix=/usr/local/cross/linux/ --with-binutils=/usr/local/ cross/linux/bin/ --with-headers=/usr/local/cross/linux/include/ libc_cv_forced_unwind=yes libc_cv_ctors_header=yes libc_cv_c_cleanup=yes
失败:
glibc 构建不久就失败了。此消息多次出现:
In file included from ./sysdeps/unix/sysdep.h:20:0,
from ./sysdeps/unix/x86_64/sysdep.h:18,
from sysdeps/unix/sysv/linux/x86_64/sysdep.h:22,
from <stdin>:1:
sysdeps/unix/sysv/linux/sys/syscall.h:24:24: fatal error: asm/unistd.h: No such file or directory
compilation terminated.
不过,这可能是正常的。
然后它无法生产stdio_lim.h
。随着make -d
,我得到这个:
Successfully remade target file `/Users/dkrauss/Documents/work/glibc-build/csu/abi-tag.h'.
Considering target file `/Users/dkrauss/Documents/work/glibc-build/bits/stdio_lim.h'.
File `/Users/dkrauss/Documents/work/glibc-build/bits/stdio_lim.h' does not exist.
Looking for an implicit rule for `/Users/dkrauss/Documents/work/glibc-build/bits/stdio_lim.h'.
Trying pattern rule with stem `lim'.
Trying implicit prerequisite `/Users/dkrauss/Documents/work/glibc-build/bits/stdio_lim.st'.
Found an implicit rule for `/Users/dkrauss/Documents/work/glibc-build/bits/stdio_lim.h'.
Considering target file `/Users/dkrauss/Documents/work/glibc-build/bits/stdio_lim.st'.
Recently tried and failed to update file `/Users/dkrauss/Documents/work/glibc-build/bits/stdio_lim.st'.
make[2]: *** No rule to make target `/Users/dkrauss/Documents/work/glibc-build/bits/stdio_lim.st', needed by `/Users/dkrauss/Documents/work/glibc-build/bits/stdio_lim.h'. Stop.
这是它尝试构建的第一个标头bits
。有一个文件stdio_lim.h.in
,它是其目录中唯一的.in
文件。是否应该连接一些.st
规则.in
?