There are two ways in cross compiling for android platform.
First, make use of arm-none-linux-gnueabi toolchain, you can download it from the following url: http://www.codesourcery.com/gnu_toolchains/arm/portal/package3399/public/arm-none-linux-gnueabi/arm-2008q3-41-arm-none-linux-gnueabi.bin
Second, use arm-gnueabi toolchain which is in NDK of Android.
Now I will tell how to cross compile for android platform by an example of compiling CyberGarage.
1. Firstly, introduce the method how to make use of arm-gnueabi toolchain. (The following referred three scripts can be extracted from attachment ” shell_cross_compiling_by_ndk.zip”)
a. Download SDK and NDK from Android official web
b. Build Android develop environment
c. Download Expat XML Parser on which is relied by CyberGarage: http://sourceforge.net/projects/expat/files/expat/2.0.1/expat-2.0.1.tar.gz/download
d. Download project CyberGarage for C from http://www.cybergarage.org/twiki/bin/view/Main/CyberLinkForC
e. Edit /etc/profile in order to add ${path}: export PATH=${PATH}:/root/Desktop/android-ndk-r4b/build/prebuilt/linux-x86/arm-eabi-4.4.0/bin
f. 1) Put “config_shell_expat” into folder “expat-2.0.1”;
2) #./config_shell_expat; (it will generate Makefile and libtool);
3) Set the line
deplibs_check_method=”pass_all”
instead of
deplibs_check_method=”unknown”
which is contained in the “libtool” script (Why need to change libtool? Because crtbegin_dynamic.o and crtend_android.o in NDK is not generated by libtool. Therefore I can say toolchain in NDK is not very perfect for porting. It needs further update in the future);
4) #make
5) #make install
g. 1) Put “config_shell_clinkc” into folder “clinkc-2.3”;
2) #./config_shell_clinkc;
3) Set the line
deplibs_check_method=”pass_all”
instead of
deplibs_check_method=”unknown”
which is contained in the “libtool” script;
4) #make
5) #make install
h. 1) Put file “make_shell” into application source folder;
2) #./make_shell;
3) you can get application under source folder
2. Then how to make use of arm-none-linux-gnueabi toolchain. (The following referred three scripts can be extracted from attachment ” shell_cross_compiling_by_gnu.zip”)
a. Download arm-none-linux-gnueabi from codesourcery;
b. Edit /etc/profile in order to add ${path}: export PATH=${PATH}:/root/CodeSourcery/Sourcery_G++_Lite/bin
c. 1) Put “config_shell_expat_gnu” into folder “expat-2.0.1”;
2) #./config_shell_expat_gnu; (it will generate Makefile and libtool);
3) #make
4) #make install
d. 1) Put “config_shell_clinkc_gnu” into folder “clinkc-2.3”;
2) #./config_shell_clinkc_gnu;
3) #make
4) #make install
e. 1) Put file “make_shell_gnu” into application source folder;
2) #./make_shell_gnu;
3) you can get application under source folder
The above two methods have been verified. If any questions, pls email me.
Thank you
Joshua
2010-10-20