标签:
之前已经在MacOS下搭建好了OpenWrt的编译环境,没想到更新到最新的官方Trunk之后,噩梦就此开始。现将思考过程以及应对方法做个记录。
OpenWrt推荐用MacPorts来搭建MacOS中的相关工具。MacOS自带了gcc,版本信息如下:
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1 Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn) Target: x86_64-apple-darwin13.4.0 Thread model: posix如果安装了mp-gcc49,则会在/opt/local/bin目录下创建gcc,其版本信息如下:
gcc (MacPorts gcc49 4.9.2_1) 4.9.2 Copyright (C) 2014 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.在搭建编译环境时,可能需要两个gcc切换(一个出错以后,切换另一个使用)。
sudo port install coreutils e2fsprogs ossp-uuid asciidoc binutils bzip2 fastjar flex getopt gtk2 intltool jikes hs-zlib openssl p5-extutils-makemaker python26 subversion rsync ruby sdcc unzip gettext libxslt bison gawk autoconf wget gmake ncurses findutils gnutar mpfr libmpc gcc49说明:mpfr libmpc非必须,系统在编译gcc时,会自动从源码编译这两个库,但如果用llvm-gcc编译时,可能会出现如下错误:
checking for the correct version of the gmp/mpfr/mpc libraries... no configure: error: Building GCC requires GMP 4.2+, MPFR 2.4.0+ and MPC 0.8.0+. Try the --with-gmp, --with-mpfr and/or --with-mpc options to specify
Undefined symbols for architecture x86_64: "_iconv", referenced from: convert_using_iconv(void*, unsigned char const*, unsigned long, _cpp_strbuf*) in libcpp.a(charset.o) (maybe you meant: __Z14cpp_init_iconvP10cpp_reader, __cpp_destroy_iconv ) "_iconv_close", referenced from: __cpp_destroy_iconv in libcpp.a(charset.o) __cpp_convert_input in libcpp.a(charset.o) "_iconv_open", referenced from: init_iconv_desc(cpp_reader*, char const*, char const*) in libcpp.a(charset.o) ld: symbol(s) not found for architecture x86_64
http://stackoverflow.com/questions/12619600/libiconv-and-macos
macports的libiconv与mac系统的不一致,此时需要做如下修改:
1.切换到mac系统的gcc
2.进入staging_dir/host/usr,创建并进入lib目录,建立/opt/local/lib/中所有libiconv开头的符号链接
Undefined symbols for architecture x86_64: "_ERR_remove_thread_state", referenced from: _rsa_sign in rsa-sign.o ld: symbol(s) not found for architecture x86_64这个问题最为奇怪,网上没有任何地方有对此问题的说明,经过仔细检查错误信息,发现在错误信息之前,有一个
HOSTLDFLAGS=“”
在mkimage的Makefile中,修改
#HOSTLDFLAGS="$(HOST_STATIC_LINKING)" define Host/Compile <span style="white-space:pre"> </span>$(MAKE) -C $(HOST_BUILD_DIR) defconfig <span style="white-space:pre"> </span>$(MAKE) -C $(HOST_BUILD_DIR) <span style="white-space:pre"> </span>HOSTLDFLAGS="-L/opt/local/lib" <span style="white-space:pre"> </span>tools-only endef
ifneq ($(HOST_OS),Darwin) ifeq ($(CONFIG_BUILD_STATIC_TOOLS),y) HOST_STATIC_LINKING = -static endif endi
ifneq ($(HOST_OS),Darwin) ifeq ($(CONFIG_BUILD_STATIC_TOOLS),y) HOST_STATIC_LINKING = -static endif else HOST_STATIC_LINKING = -L/opt/local/lib endif
在第二个问题的处理上纠缠了很久。看来在MacOS下搭建OpenWrt的编译环境确实是一个比较“蛋疼”的举动
Mac OS下搭建OpenWrt编译环境记录(针对官方最新2015.01.20之trunk)
标签:
原文地址:http://blog.csdn.net/manfeel/article/details/43088363