ftp://ftp.bluage.com/eclipse45/eclipse-cpp-mars-R-linux-gtk-x86_64.tar.gz
ftp://ftp.bluage.com/eclipse45/eclipse-cpp-mars-R-win32-x86_64.zip
CentOS 7 + android-ndk-r10d-linux-x86_64.bin + eclipse-cpp-luna-SR2-linux-gtk-x86_64.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
------------ compile c++ ------------
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
eclipse的设置如下:
Tool Chain Editor:
Debug [Active]
Cross GCC
Gnu Make Builder
Used tools:
Cross GCC Compiler
Cross G++ Compiler
Cross GCC Linker
Cross G++ Linker
Cross GCC Archiver
Cross GCC Assembler
cross settings:
arm-linux-androideabi-
/opt/android-on-linux/android-ndk-r10d/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64
cross g++ compiler:
Include paths(-I):
/opt/android-on-linux/android-ndk-r10d/sources/cxx-stl/stlport/stlport
/opt/android-on-linux/android-ndk-r10d/platforms/android-21/arch-arm/usr/include
/opt/android-on-linux/android-ndk-r10d/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/include
/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
/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
Miscellaneous: --->
other flags: -c -fmessage-length=0 -DANDROID -fno-exceptions
勾选: -fPIC
cross g++ linker:
all options: -nostdlib -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/
general: -nostdlib
Libraries:
(-l) stdc++ stlport c
(-L) /opt/android-on-linux/android-ndk-r10d/sources/cxx-stl/stlport/libs/armeabi-v7a
/opt/android-on-linux/android-ndk-r10d/platforms/android-21/arch-arm/usr/lib/
--------------------------
因为 手机上 是| /system/lib/libstlport.so
所以,
[root@localhost armeabi-v7a]# pwd
/opt/android-on-linux/android-ndk-r10d/sources/cxx-stl/stlport/libs/armeabi-v7a
[root@localhost armeabi-v7a]# adb pull /system/lib/libstlport.so .
[root@localhost armeabi-v7a]# chmod 755 libstlport.so
--------------------------
Miscellaneous:
Other options:
-R/opt/android-on-linux/android-ndk-r10d/platforms/android-21/arch-arm/usr/lib
Other objects:
/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
+++++++++++ eclipse编译过程 出错
>>>>>>>>
/opt/android-on-linux/android-ndk-r10d/sources/cxx-stl/stlport/stlport/stl/_ostream.h:187: error: undefined reference to 'std::uncaught_exception()'
collect2: error: ld returned 1 exit status
make: *** [helloworldcpp] 错误 1
>>>>>>>>
解决方法:
[root@localhost arm-linux-androideabi-4.9]# gedit /opt/android-on-linux/android-ndk-r10d/sources/cxx-stl/stlport/stlport/stl/_ostream.h
将187行
~sentry() {
if (_M_str.flags() & ios_base::unitbuf)
#if !defined (_STLP_NO_UNCAUGHT_EXCEPT_SUPPORT)
if (!uncaught_exception())
#endif
_M_str.flush();
}
修改为:
~sentry() {
}
+++++++++++ eclipse编译过程
23:32:03 **** Incremental Build of configuration Debug for project helloworldcpp ****
make all
Building file: ../src/helloworldcpp.cpp
Invoking: Cross G++ Compiler
arm-linux-androideabi-g++ -I/opt/android-on-linux/android-ndk-r10d/sources/cxx-stl/stlport/stlport -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/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/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 -O0 -g3 -Wall -c -fmessage-length=0 -DANDROID -fno-exceptions -fPIC -MMD -MP -MF"src/helloworldcpp.d" -MT"src/helloworldcpp.d" -o "src/helloworldcpp.o" "../src/helloworldcpp.cpp"
Finished building: ../src/helloworldcpp.cpp
Building target: helloworldcpp
Invoking: Cross G++ Linker
arm-linux-androideabi-g++ -nostdlib -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/ -Xlinker -R/opt/android-on-linux/android-ndk-r10d/platforms/android-21/arch-arm/usr/lib -o "helloworldcpp" ./src/helloworldcpp.o /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
Finished building target: helloworldcpp
23:32:04 Build Finished (took 311ms)
+++++++++++
++++++++ 在CentOS 7
[root@localhost helloworldcpp]# pwd
/opt/eclipse-workspace/helloworldcpp
[root@localhost helloworldcpp]# ls
Debug src
[root@localhost helloworldcpp]# cd Debug/
[root@localhost Debug]# pwd
/opt/eclipse-workspace/helloworldcpp/Debug
[root@localhost Debug]# ls
helloworldcpp makefile objects.mk sources.mk src
[root@localhost Debug]# adb push helloworldcpp /data/data/
4063 KB/s (102700 bytes in 0.024s)
[root@localhost Debug]#
+++++++++ Android (ARM)
[root@localhost Debug]# adb root
[root@localhost Debug]# adb shell
root@mb526:/ # cd data/data
root@mb526:/data/data # ./helloworldcpp
!!!Hello World!!!
阅读(1340) | 评论(0) | 转发(0) |