( OK—C程序 ) Eclipse C/C++ — CentOS 7 + android-ndk + eclipse-cpp-mars-R

Posted ztguang_张同光

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了( OK—C程序 ) Eclipse C/C++ — CentOS 7 + android-ndk + eclipse-cpp-mars-R相关的知识,希望对你有一定的参考价值。


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 gcc compiler:


Include paths(-I):

/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 gcc linker:

all options:  -nostdlib -L/opt/android-on-linux/android-ndk-r10d/platforms/android-21/arch-arm/usr/lib/

general:  -nostdlib


Libraries:

(-l)  c

(-L)  /opt/android-on-linux/android-ndk-r10d/platforms/android-21/arch-arm/usr/lib/


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编译过程

09:09:30 **** Incremental Build of configuration Debug for project helloworldc ****

make all

Building file: ../src/helloworldc.c

Invoking: Cross GCC Compiler

arm-linux-androideabi-gcc -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 -O0 -g3 -Wall -c -fmessage-length=0 -DANDROID -fno-exceptions -fPIC -MMD -MP -MF"src/helloworldc.d" -MT"src/helloworldc.d" -o "src/helloworldc.o" "../src/helloworldc.c"

Finished building: ../src/helloworldc.c


Building target: helloworldc

Invoking: Cross GCC Linker

arm-linux-androideabi-gcc -nostdlib -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 "helloworldc"  ./src/helloworldc.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 -lc

Finished building target: helloworldc



09:09:32 Build Finished (took 1s.269ms)


+++++++++++++++


++++++++ 在CentOS 7

[root@localhost helloworldc]# pwd

/opt/eclipse-workspace/helloworldc

[root@localhost helloworldc]# ls

Debug  src

[root@localhost Debug]# pwd

/opt/eclipse-workspace/helloworldc/Debug

[root@localhost Debug]# ls

helloworldc  makefile  objects.mk  sources.mk  src

[root@localhost Debug]# adb push helloworldc /data/data/

* daemon not running. starting it now on port 5037 *

* daemon started successfully *

718 KB/s (30436 bytes in 0.041s)

[root@localhost Debug]#


+++++++++ Android (ARM)

[root@localhost Debug]# adb root

[root@localhost Debug]# adb shell

root@mb526:/ # cd data/data

root@mb526:/data/data # ./helloworldc                                       

!!!Hello World!!!


以上是关于( OK—C程序 ) Eclipse C/C++ — CentOS 7 + android-ndk + eclipse-cpp-mars-R的主要内容,如果未能解决你的问题,请参考以下文章

点击 OK 后设置 C/C++ 构建配置恢复为默认值

Eclipse 4.4.1 (Luna) for C/C++ Programming

Eclipse Neon 配置C/C++开发环境

STM32CubeIDE 编译C/C++程序

为啥在eclipse中这个程序无法编译通过?

当宏是函数参数时的 Eclipse C/C++ 格式化程序换行或缩进问题