开发者

Cross-compiler for Linux on Mac OS X?

I've been reading lots of documents on the internet about creating a cross compiler for linux on mac os x but can't seam to get any to work.

It seams as if no one can help me with the question: Getting GMP to work with GCC 4.5.2

Is there any easy'er way to create a cross c开发者_如何学JAVAompiler?


You need to:

  1. install the xcode base build tools
  2. install the optional xcode command line tools
  3. install homebrew
  4. install the homebrew build tools
    4.1 brew install crosstool-ng mpfr gmp grep
    4.2 brew tap homebrew/dupes
  5. create a case sensitive volume using "disk utility"
  6. use this volume to build the tool chain itself
    6.1 generate a base configuration (for me this is an arm cortex a8)
    6.1.1 ct-ng arm-cortex_a8-linux-gnueabi
    6.2 use menuconfig (ct-ng menuconfig) to tweak the configuration
    6.2.1. disable fortran and java (c compiler)
    6.2.2. turn off static linking (c compiler)
    6.2.3. change the paths to be on the volume you created above (paths and misc options)
    6.2.4. remove dmalloc (debug facilities)
    6.3 invoke the build:
    6.3.1 ulimit -n 1024
    6.3.2 ct-ng build

with much thanks to the crosstools-ng list.


In order to build binaries for architectures different that your build host, you need far more than just a cross-compiler - you need a full-blown toolchain, which can be a real pain to create, as you probably discovered.

A couple of approaches:

  • Use a proper Linux distribution in a virtual machine, such as VirtualBox. If you only want to build binaries for Linux/i386 on an MacOSX/x86_64 host, this is - in my opinion - the easiest, safest and most clean solution. It is not a cross-compiler, of course, but it works and it has the added advantage that you can actually test your executables.

  • Use a script such crosstool-NG (a descendant of the original crosstool) to automatically build the toolchain - definitely easier than building it on your own, although you may have to compromise for slightly older compiler versions.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜