mac交叉编译

https://github.com/crosstool-ng/crosstool-ng/releases
下载最新版

该分支对编译中出现的一些编译error,进行了修正,并对mulitlib的编译进行了一定程度的修正

编译和安装

cd crosstool-ng
 xattr -d com.apple.quarantine ./configure //bad interpreter: Operation not permitted
chmod 777 ./configure

指定安装路径(默认安装在/usr/local下).,和mac下的一些ports工具,如gobjcopy,这些可以通过mac-ports 安装

./bootstrap 
./configure --prefix=${install_path} --with-objcopy=/opt/local/bin/gobjcopy --with-objdump=/opt/local/bin/gobjdump --with-libtool=/opt/local/bin/glibtool --with-readelf=/opt/local/bin/greadelf --with-gbtoolize=/opt/local/bin/glibtoolize 
make
make install

使用crosstool-ng编译arm工具链

ct-ng menuconfig
由于mac有些限制,有些地方需要特别设定下
具体步骤如下:
make version 3.82在编译glibc时有问题,打开EXPERIMENTAL feature以便使用自带的make
Paths and misc options ---> [*] Try features marked as EXPERIMENTAL

打开debug功能,以便可以进行单个step的编译,而不是每次都重新编译所有的

Paths and misc options  ---> [*] Debug crosstool-NG 
                                             ---> Debug crosstool-NG  
                                                     ---> gzip saved states (NEW)
Paths and misc options  ---> Maximum log level to see: (INFO) 

根据自己的需要定制cpu

Target options  --->   Target Architecture (arm)
Target options  --->   (armv6k) Architecture level
Target options  --->   (arm1176jzf-s) Tune for CPU
Target options  --->   (vfp) Use specific FPU
 
Operating System  --->  Target OS (linux) 
Operating System  --->  Linux kernel version (2.6.32.60 (longterm))
 
C compiler  ---> C compiler (gcc) 
C compiler  ---> [*] Show Linaro versions
C compiler  ---> gcc version (linaro-4.6-2013.04)
C compiler  ---> [*] C++

apple gcc不支持静态链接,关闭静态链接

C compiler  ---> [ ] Link libstdc++ statically into the gcc binary

这里使用glibc 2.13

C-library  --->  C library (glib) 
C-library  --->  glibc version (2.13)

使用4.3.2的GMP,5.0+的存在编译问题

Companion libraries  ---> GMP version (4.3.2)

编译自定义的make,

Companion tools  --->  [*] Build some companion tools 
Companion tools  --->  [*]   make

Esc Esc 保存并退出设定界面

编译工具链

ct-ng build

编译完成后,工具链默认存放在在~/x-tools/下


image.png

你可能感兴趣的:(mac交叉编译)