CodeBlocks
全局编译参数(
Settings->Compiler
)具体设置,
参考 http://blog.chinaunix.net/uid-14735472-id-5194999.html
打开CodeBlocks,选择菜单Settings->Compiler 在弹出的窗口中选取GNU ARM GCC Compiler,当然也可以Copy一个新的,重命名为GNU ARM GCC Compiler For Android,再进行如下设置:
上图中,都不选。
上图和下图是一个内容
-------------- Build: Debug in helloworld (compiler: GNU ARM GCC Compiler For Android)---------------
//编译命令
arm-linux-androideabi-g++ -Wall -O0 -g3 -fPIC -c -fmessage-length=0 -fno-exceptions -MMD -MP -DANDROID -I/opt/android-on-linux/android-ndk-r10d/sources/cxx-stl/stlport/stlport -I/opt/android-on-linux/android-ndk-r10d/platforms/android-21/arch-arm/usr/include -I/opt/android-on-linux/android-ndk-r10d/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/include -I/opt/android-on-linux/android-ndk-r10d/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9/include-fixed -I/opt/android-on-linux/android-ndk-r10d/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9/include -c main.cpp -o obj/Debug/main.o
//链接命令
arm-linux-androideabi-g++ -L/opt/android-on-linux/android-ndk-r10d/sources/cxx-stl/stlport/libs/armeabi-v7a -L/opt/android-on-linux/android-ndk-r10d/platforms/android-21/arch-arm/usr/lib/ -o bin/Debug/helloworld obj/Debug/main.o -nostdlib -Xlinker -R/opt/android-on-linux/android-ndk-r10d/platforms/android-21/arch-arm/usr/lib /opt/android-on-linux/android-ndk-r10d/platforms/android-21/arch-arm/usr/lib/crtbegin_dynamic.o /opt/android-on-linux/android-ndk-r10d/platforms/android-21/arch-arm/usr/lib/crtend_android.o -lstdc++ -lstlport -lc
//结果
Output file is bin/Debug/helloworld with size 100.25 KB
Process terminated with status 0 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))
//测试
[root@localhost Debug]# pwd
/opt/codeblosks-workspace/helloworld/bin/Debug
[root@localhost Debug]# ls
helloworld
[root@localhost Debug]# file helloworld
helloworld: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), not stripped
[root@localhost Debug]# adb root
[root@localhost Debug]# adb push helloworld /data/data/
3221 KB/s (101856 bytes in 0.030s)
[root@localhost Debug]# adb shell
root@mb526:/data/data # ./helloworld
Hello world!
参考 http://blog.chinaunix.net/uid-14735472-id-5194999.html
打开CodeBlocks,选择菜单Settings->Compiler 在弹出的窗口中选取GNU ARM GCC Compiler,当然也可以Copy一个新的,重命名为GNU ARM GCC Compiler For Android,再进行如下设置:
![](https://i-blog.csdnimg.cn/blog_migrate/77210864e2d2ad18c236a1dde12ceaeb.png)
上图中,都不选。
![](https://i-blog.csdnimg.cn/blog_migrate/68553709b1b0330f9450443245ba75c4.png)
![](https://i-blog.csdnimg.cn/blog_migrate/d26f3554251dea603d78f9d5f52531c4.png)
上图和下图是一个内容
![](https://i-blog.csdnimg.cn/blog_migrate/ea5cfed37600ee641f21e14e2d8e6d58.png)
![](https://i-blog.csdnimg.cn/blog_migrate/6e04f384fad4e7c0ee0467b43bcde227.png)
![](https://i-blog.csdnimg.cn/blog_migrate/addfbcfecc6da60c6b24e13fed099610.png)
![](https://i-blog.csdnimg.cn/blog_migrate/8a6a9154670ff961f728752d35bb983f.png)
-------------- Build: Debug in helloworld (compiler: GNU ARM GCC Compiler For Android)---------------
//编译命令
arm-linux-androideabi-g++ -Wall -O0 -g3 -fPIC -c -fmessage-length=0 -fno-exceptions -MMD -MP -DANDROID -I/opt/android-on-linux/android-ndk-r10d/sources/cxx-stl/stlport/stlport -I/opt/android-on-linux/android-ndk-r10d/platforms/android-21/arch-arm/usr/include -I/opt/android-on-linux/android-ndk-r10d/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/include -I/opt/android-on-linux/android-ndk-r10d/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9/include-fixed -I/opt/android-on-linux/android-ndk-r10d/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9/include -c main.cpp -o obj/Debug/main.o
//链接命令
arm-linux-androideabi-g++ -L/opt/android-on-linux/android-ndk-r10d/sources/cxx-stl/stlport/libs/armeabi-v7a -L/opt/android-on-linux/android-ndk-r10d/platforms/android-21/arch-arm/usr/lib/ -o bin/Debug/helloworld obj/Debug/main.o -nostdlib -Xlinker -R/opt/android-on-linux/android-ndk-r10d/platforms/android-21/arch-arm/usr/lib /opt/android-on-linux/android-ndk-r10d/platforms/android-21/arch-arm/usr/lib/crtbegin_dynamic.o /opt/android-on-linux/android-ndk-r10d/platforms/android-21/arch-arm/usr/lib/crtend_android.o -lstdc++ -lstlport -lc
//结果
Output file is bin/Debug/helloworld with size 100.25 KB
Process terminated with status 0 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))
//测试
[root@localhost Debug]# pwd
/opt/codeblosks-workspace/helloworld/bin/Debug
[root@localhost Debug]# ls
helloworld
[root@localhost Debug]# file helloworld
helloworld: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), not stripped
[root@localhost Debug]# adb root
[root@localhost Debug]# adb push helloworld /data/data/
3221 KB/s (101856 bytes in 0.030s)
[root@localhost Debug]# adb shell
root@mb526:/data/data # ./helloworld
Hello world!