Mac OS下搭建OpenWrt编译环境记录(针对官方最新2015.01.20 r44068 trunk)
来源:互联网 发布:centos supervisor 编辑:程序博客网 时间:2024/06/05 04:14
前言
之前已经在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.1Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)Target: x86_64-apple-darwin13.4.0Thread model: posix如果安装了mp-gcc49,则会在/opt/local/bin目录下创建gcc,其版本信息如下:
gcc (MacPorts gcc49 4.9.2_1) 4.9.2Copyright (C) 2014 Free Software Foundation, Inc.This is free software; see the source for copying conditions. There is NOwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.在搭建编译环境时,可能需要两个gcc切换(一个出错以后,切换另一个使用)。
首先,请确保安装了如下macports工具库
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... noconfigure: 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
问题描述
问题1:
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
碰到此种情况,说明你用的是mp-gcc49编译的,在这个地址有关于此错误的描述
http://stackoverflow.com/questions/12619600/libiconv-and-macos
macports的libiconv与mac系统的不一致,此时需要做如下修改:
1.切换到mac系统的gcc
2.进入staging_dir/host/usr,创建并进入lib目录,建立/opt/local/lib/中所有libiconv开头的符号链接
问题2:
Undefined symbols for architecture x86_64: "_ERR_remove_thread_state", referenced from: _rsa_sign in rsa-sign.old: symbol(s) not found for architecture x86_64这个问题最为奇怪,网上没有任何地方有对此问题的说明,经过仔细检查错误信息,发现在错误信息之前,有一个
HOSTLDFLAGS=“”
在mkimage的Makefile中,修改
#HOSTLDFLAGS="$(HOST_STATIC_LINKING)"define Host/Compile -C $(HOST_BUILD_DIR) defconfig $(MAKE) -C $(HOST_BUILD_DIR) \ HOSTLDFLAGS="-L/opt/local/lib" \ tools-onlyendef
实际上HOSTLDFLAGS在include/host-build.mk中定义:
ifneq ($(HOST_OS),Darwin) ifeq ($(CONFIG_BUILD_STATIC_TOOLS),y) HOST_STATIC_LINKING = -static endifendi
如果不是Darwin(MacOS),则设置为-static,否则,否则,否则呢!?就不设置任何的值。可以修改此处为:
ifneq ($(HOST_OS),Darwin) ifeq ($(CONFIG_BUILD_STATIC_TOOLS),y) HOST_STATIC_LINKING = -static endifelse HOST_STATIC_LINKING = -L/opt/local/libendif
总结
在第二个问题的处理上纠缠了很久。看来在MacOS下搭建OpenWrt的编译环境确实是一个比较“蛋疼”的举动
1 0
- Mac OS下搭建OpenWrt编译环境记录(针对官方最新2015.01.20 r44068 trunk)
- Mac OS下Linphone SDK的编译环境搭建
- Mac OS X下NDK环境的搭建及编译
- 在Mac OS X下搭建gtk编译环境
- 联发科Linkit 7688 (一) 上手及在Mac下搭建OpenWrt交叉编译环境,C语言编译Hello,World
- ubuntu12.04下搭建Openwrt编译环境
- ContOS下编译搭建openwrt环境
- 搭建OpenWRT编译环境
- openwrt编译环境搭建
- openwrt编译环境搭建
- openwrt编译环境搭建
- Mac OS X下搭建nRF51822G0(第二代)开发环境
- Mac os 下搭建iOS开发环境
- Mac os 下搭建iOS开发环境
- 在windows环境下搭建mac os
- Mac OS X下搭建NDK环境
- Mac OS下搭建python+selenium环境
- Mac OS 环境下如何编译OpenCV
- C语言 函数定义及调用
- CSS3中 @font-face用法介绍
- Think in Java(六):接口
- PAT 1014. 福尔摩斯的约会 (20)
- cortex_m3_stm32嵌入式学习笔记(十六):ADC实验(模数转换)
- Mac OS下搭建OpenWrt编译环境记录(针对官方最新2015.01.20 r44068 trunk)
- IOS框架和服务
- nios 自定义IP
- (一)s5pv210启动方式
- Python特性
- linux grep命令
- 思科CCNA第二学期第十章答案
- Unity3d 游戏资源打包加密(图片/XML/TXT等) C#编码 (一)
- 不忘初心