Build openwrt compilation environment record under Mac OS (for the official latest 2015.01.20 trunk)

Source: Internet
Author: User
Tags gmp

Preface

It has been built in MacOS under the OpenWrt of the compilation environment, did not expect to update to the latest official trunk, the nightmare began. A record of the thinking process and the coping methods are now made.


Background Knowledge

OpenWrt recommends using MacPorts to build relevant tools in MacOS. MacOS comes with GCC with the following version information:

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
If mp-gcc49 is installed, GCC is created under the/opt/local/bin directory with the following version information:

GCC (macports gcc49 4.9.2_1) 4.9.2Copyright (C) free software Foundation, inc.this are free software; See the source for copying conditions.  There is nowarranty; Not even to merchantability or FITNESS for A particular PURPOSE.
When setting up a compilation environment, you may need two GCC switches (one after the error, the other used).

First, make sure that you have installed the following MacPorts tool library

sudo port install coreutils e2fsprogs ossp-uuid asciidoc binutils bzip2   Fastjar flex getopt gtk2 intltool jikes Hs-zli  b OpenSSL p5-extutils-makemaker   python26 subversion rsync Ruby SDCC unzip gettext libxslt Bison gawk autoconf   wget Gmake ncurses findutils gnutar MPFR libmpc gcc49
Description: MPFR LIBMPC is not required, the system compiles the GCC automatically from the source code when compiling the two libraries, but if you compile with LLVM-GCC, the following error may occur:

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

Problem DescriptionQuestion 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, 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) isn't found for architecture x86_64

In this case, you are using mp-gcc49 compiled, at this address there is a description of this error

Http://stackoverflow.com/questions/12619600/libiconv-and-macos

MacPorts's libiconv is inconsistent with the Mac system and needs to be modified as follows:

1. Switch to GCC for Mac system

2. Enter STAGING_DIR/HOST/USR, create and enter the Lib directory, and establish a symbolic link to start all libiconv in the/opt/local/lib/


Question 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
This is the most strange question, there is no place on the internet to explain the problem, after careful examination of the error message, found in the error message, there is a

Hostldflags= ""

In the makefile of Mkimage, modify

#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-onlyendef

In fact, hostldflags is defined in INCLUDE/HOST-BUILD.MK:

Ifneq ($ (host_os), Darwin)  ifeq ($ (config_build_static_tools), y)    host_static_linking =-static  Endifendi

If it is not Darwin (MacOS), then set to-static, otherwise, otherwise!? No value is set. Can be modified here to:

Ifneq ($ (host_os), Darwin)  ifeq ($ (config_build_static_tools), y)    host_static_linking =-static  Endifelse  host_static_linking =-l/opt/local/libendif

Summarize

had been entangled for a long time on the handling of the second problem. It seems that building openwrt under MacOS is really a "egg-ache" move.




Build openwrt compilation environment record under Mac OS (for the official latest 2015.01.20 trunk)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.