How to cross compile with xmake

xmake provides convenient and flexible cross-compilation support. In most cases, there is no need to configure complex toolchains prefixes, such as: arm-linux-something

As long as the toolchains directory satisfies the following structure (most of the cross toolchains have this structure):

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

Then, when using xmake to cross compile, you only need to configure and compile as follows:

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

Xmake will automatically detect the prefix name of compilers such as gcc:, arm-linux-and when compiling, it will also automatically add search options for link libraries and header files:

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

These are handled automatically by xmake, and there is no need to configure them manually. .

However, the situation with some exceptions, such as some special cross-toolchain, compiler bin directory, not in /home/toolchains_sdkdir/binthis position, but to independent /usr/opt/bin, how to do it, in fact, do not bother, configuration time, and then specify the bin The location of the directory is just fine:

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

If this tool chain is very weird, that is, cards are not played according to the rules, and the path rules are messy, then xmake can't be so smart, and can only manually configure all the parameters:

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

In addition, if the prefix of the cross tool chain, for example: arm-linux-xmake is not detected successfully, you can also --cross=manually configure it through parameters:

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

Personal homepage: TBOOX open source project
Original source: http://tboox.org/cn/2016/07/22/how-to-compile-on-cross-toolchains/

Guess you like

Origin blog.csdn.net/waruqi/article/details/53201568