Android中使用Makefile编译程序和库的方法(2)

Makefile.am内容如下   

 

AUTOMAKE_OPTIONS = foreign    bin_PROGRAMS = test    test_SOURCES = test.c  

 

依次执行

aclocal

autoheader

autoconf

automake --add-missing

编写脚本build.sh,内容如下

 

CC=arm-eabi-gcc \    LD=arm-eabi-gcc \    CFLAGS="-I/home/apuser/Downloads/Android-ndk/android-ndk-r4/build/platforms/android-8/arch-arm/usr/include" \    LDFLAGS="-L/home/apuser/Downloads/android-ndk/android-ndk-r4/build/platforms/android-8/arch-arm/usr/lib -nostdlib -lm -lstdc++ -lc -ldl -Bdynamic -Wl,-dynamic-linker,/system/bin/linker /home/apuser/Downloads/android-ndk/android-ndk-r4/build/platforms/android-8/arch-arm/usr/lib/crtbegin_dynamic.o /home/apuser/Downloads/android-ndk/android-ndk-r4/build/platforms/android-8/arch-arm/usr/lib/crtend_android.o" \    ./configure \            --build=i386-linux \             --host=arm-elf-linux \  

 
    执行脚本build.sh后编译即可。

另有Funambol的脚本,也可使用,内容如下   

 

command for C compiller:    ./configure --host=arm-eabi CC=arm-eabi-gcc CPPFLAGS="-I$ANDROID_ROOT/build/platforms/android-5/arch-arm/usr/include/" CFLAGS="-nostdlib -fno-exceptions -fno-rtti -Wno-multichar" LDFLAGS="-Wl,-rpath-link=$ANDROID_ROOT/build/platforms/android-5/arch-arm/usr/lib/ -L$ANDROID_ROOT/build/platforms/android-5/arch-arm/usr/lib/" LIBS="-lc"   command for C++ compiller:    ./configure --host=arm-eabi CXX=arm-eabi-g++ CPPFLAGS="-I$ANDROID_ROOT/build/platforms/android-5/arch-arm/usr/include/ -nostdlib -fno-exceptions -fno-rtti -Wno-multichar" LDFLAGS="-Wl,-rpath-link=$ANDROID_ROOT/build/platforms/android-5/arch-arm/usr/lib/ -L$ANDROID_ROOT/build/platforms/android-5/arch-arm/usr/lib/" LIBS="-lc"  

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wwxfxx.html