How to complie project using the cross-toolchains

2016-07-22 ruki 更多博文 » 博客 » GitHub »

xmake cross-toolchains cross-compiling

原文链接 https://waruqi.github.io/2016/07/22/how-to-compile-on-cross-toolchains/
注:以下为加速网络访问所做的原文缓存,经过重新格式化,可能存在格式方面的问题,或偶有遗漏信息,请以原文为准。


xmake provides a convenient and flexible cross-compiling support, in most cases, we need not to configure complex toolchains prefix, for example: arm-linux-

As long as this toolchains meet the following directory structure:

/home/toolchains_sdkdir
   - bin
       - arm-linux-gcc
       - arm-linux-ld
       - ...
   - lib
       - libxxx.a
   - include
       - xxx.h

Then,we can only configure the sdk directory and build it.

$ xmake f -p linux --sdk=/home/toolchains_sdkdir
$ xmake

xmake will detect the prefix: arm-linux- and add the include and library search directory automatically.

-I/home/toolchains_sdkdir/include -L/home/toolchains_sdkdir/lib

However, we need set it manually if the toolchains /bin directory is in other places.

$ xmake f -p linux --sdk=/home/toolchains_sdkdir --toolchains=/usr/opt/bin
$ xmake

Or we need configure all options for compiling successfully if this toolchains has completely differen directory structure.

$ xmake f -p linux --sdk=/home/toolchains_sdkdir --toolchains=/usr/opt/bin --cxflags="-I/usr/xxx/include" --ldflags="-L/usr/zzz/lib"
$ xmake

We can also set the prefix using the argument --cross= manually.

.e.g

$ xmake f -p linux --cross=arm-linux- --sdk=/home/toolchains_sdkdir ...