我用下面的方法去编译,但是弹出很多错误信息,你知道是为什么吗? cd ~/android-ndk-r6b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin ./arm-linux-androideabi-gcc -o hello ~/workspace_c/v4l2/jni/hello.c In file included from /home/liuqiangjin/workspace_c/v4l2/jni/hello.c:1: ./../lib/gcc/arm-linux-androideabi/4.4.3/include-fixed/stdio.h:50:23: error: sys/cdefs.h: No such file or directory ./../lib/gcc/arm-linux-androideabi/4.4.3/include-fixed/stdio.h:51:24: error: sys/_types.h: No such file or directory In file included from /home/liuqiangjin/workspace_c/v4l2/jni/hello.c:1: ./../lib/gcc/arm-linux-androideabi/4.4.3/include-fixed/stdio.h:163: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'extern'./../lib/gcc/arm-linux-androideabi/4.4.3/include-fixed/stdio.h:232: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__BEGIN_DECLS' ./../lib/gcc/arm-linux-androideabi/4.4.3/include-fixed/stdio.h:382: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__BEGIN_DECLS' ./../lib/gcc/arm-linux-androideabi/4.4.3/include-fixed/stdio.h:393: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'static'
./hello: 1: Syntax error: word unexpected (expecting ")")这个错误一般是因为android没有glibc库造成的,你可以用静态编译解决这个问题
看到一种说法 是用c遍了在编译过来 不过感觉c不可以 应该用c++等才行把 因为c没有类的。。
我希望这个c/c++程序和java分离开。
生成的可执行文件可以通过jni去调用,手动执行或在init.rc中启动
可以不用Android.mk那一套,编译器在pribuild下,比如arm-*-gcc -o test test.c,这样编译出来的可执行文件可以直接在adb shell中使用
只要写好makefile就可以了,然后编译,mmm external/xxx,重新编译system.img,make snod
然后进入adb,
#adb shell
#cd /system/bin
#ls -l xxx
#./xxx就可以执行你自己写的程序了
如果确实需要原子操作,android的ndk中提供有其他接口可以使用
你好,你可以告诉我external是在哪个下面吗?NDK目录下面吗?
# ./hello
./hello: 1: Syntax error: word unexpected (expecting ")")
我也不知道是什么原因。helloworld程序在仿真器和真机上运行有区别吗?对了,我想起来了,仿真器一般是基于arm架构的。我的真机是Intel的IA架构的。你们知道怎么去修改吗?是不是编译的toolchain需要改,但是我不知道怎么改。
我用下面的方法去编译,但是弹出很多错误信息,你知道是为什么吗?
cd ~/android-ndk-r6b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin
./arm-linux-androideabi-gcc -o hello ~/workspace_c/v4l2/jni/hello.c
In file included from /home/liuqiangjin/workspace_c/v4l2/jni/hello.c:1:
./../lib/gcc/arm-linux-androideabi/4.4.3/include-fixed/stdio.h:50:23: error: sys/cdefs.h: No such file or directory
./../lib/gcc/arm-linux-androideabi/4.4.3/include-fixed/stdio.h:51:24: error: sys/_types.h: No such file or directory
In file included from /home/liuqiangjin/workspace_c/v4l2/jni/hello.c:1:
./../lib/gcc/arm-linux-androideabi/4.4.3/include-fixed/stdio.h:163: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'extern'./../lib/gcc/arm-linux-androideabi/4.4.3/include-fixed/stdio.h:232: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__BEGIN_DECLS'
./../lib/gcc/arm-linux-androideabi/4.4.3/include-fixed/stdio.h:382: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__BEGIN_DECLS'
./../lib/gcc/arm-linux-androideabi/4.4.3/include-fixed/stdio.h:393: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'static'