我正在尝试构建 binutils 以在 Mac OS X 上生成 MIPS 代码。
我找到了这个网站(http://www.theairportwiki.com/index.php/Building_a_cross_compile_of_GCC_for_MIPS_on_OS_X http://www.theairportwiki.com/index.php/Building_a_cross_compile_of_GCC_for_MIPS_on_OS_X) from 如何在 Mac OS X 主机上为 MIPS 目标构建 GCC 4.8.x https://stackoverflow.com/questions/22776307/how-to-build-gcc-4-8-x-on-mac-os-x-host-for-mips-target,并按照说明进行操作。
我从brew安装了gcc-4.8,并安装了binutils和gcc的源代码。这是编译选项设置。
$ export CC=/usr/local/bin/gcc-4.8
$ export CXX=/usr/local/bin/g++-4.8
$ export CPP=/usr/local/bin/cpp-4.8
$ export LD=/usr/local/bin/gcc-4.8
$ export PREFIX=/opt/cross/gcc-mips
$ export CFLAGS=-Wno-error=deprecated-declarations
然后我配置并制作 binutils。
问题是,在构建静态库后,我收到一条错误消息,指出归档不是为构建的x86_64
,然后我有一堆未定义的符号错误。
ignoring file ./../intl/libintl.a, file was built for archive which is not the architecture being linked (x86_64): ./../intl/libintl.a
Undefined symbols for architecture x86_64:
"__bfd_abort", referenced from:
_fix_new_internal in write.o
_size_seg in write.o
谷歌搜索发现我也需要设置 AR(存档)变量https://github.com/tpoechtrager/osxcross/issues/11 https://github.com/tpoechtrager/osxcross/issues/11。我添加了export AR=/usr/local/bin/gcc-ar-4.8
,但我有另一个错误消息,因为 gcc-ar-4.8 不起作用。
/usr/local/bin/gcc-ar-4.8
/usr/local/bin/gcc-ar-4.8: Cannot find plugin 'liblto_plugin.so'
再次谷歌搜索发现 gcc-ar 不适用于 Mac OS X (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56893 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56893).
gcc-ar is for use with newer GNU binutils only as that is the only ar which supports plugins.
Apple's ar does not support plugins (though it could be made to; it will be a different plugin interface than the GNU BFD
plugin interface which GCC supports right now).
我刚刚创建了一个愚蠢的“liblto_plugin.so”文件/usr/local/Cellar/gcc48/4.8.4/libexec/gcc/x86_64-apple-darwin14.3.0/4.8.4
目录以抑制错误消息,但在本例中它看起来像这样/usr/ar
当我使用时被调用/usr/bin/gcc-ar-4.8
获得相同的体系结构和未定义的符号错误。
如何解决这些问题?如何在 Mac OS X 上构建交叉编译工具(gcc 和 binutils)?