ubuntu下关于ndk编译报错的现象[[obj/local/arm64-v8a/objs/hello-jni/hello-jni.o] ]

ubuntu下关于ndk编译报错的现象:

在windows下进行ndk编译一般情况下直接通过ndk-build就直接编译了,今天晚上偶然在ubutun下装了个ndk,直接编译sample里面想试一下,结果报错了

错误信息如下:

[arm64-v8a] Compile        : hello-jni <= hello-jni.c
jni/hello-jni.c:17:20: fatal error: /home/dean/android-ndk-r10b/platforms/android-L/arch-arm64/usr/include/string.h: Permission denied
 #include 
                    ^
compilation terminated.
make: *** [obj/local/arm64-v8a/objs/hello-jni/hello-jni.o] Error 1

刚看到错误觉得可能是权限问题吧,所以直接去把这个string.h的文件的权限修改了,再次编译:

[arm64-v8a] Compile        : hello-jni <= hello-jni.c
[arm64-v8a] SharedLibrary  : libhello-jni.so
/home/dean/android-ndk-r10b/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/aarch64-linux-android/4.9/../../../../aarch64-linux-android/bin/ld: cannot find crtbegin_so.o: 没有那个文件或目录
/home/dean/android-ndk-r10b/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/aarch64-linux-android/4.9/../../../../aarch64-linux-android/bin/ld: cannot find -lstdc++
/home/dean/android-ndk-r10b/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/aarch64-linux-android/4.9/../../../../aarch64-linux-android/bin/ld: cannot find -lm
/home/dean/android-ndk-r10b/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/aarch64-linux-android/4.9/../../../../aarch64-linux-android/bin/ld: cannot find -lc
/home/dean/android-ndk-r10b/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/aarch64-linux-android/4.9/../../../../aarch64-linux-android/bin/ld: cannot find -lc
/home/dean/android-ndk-r10b/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/aarch64-linux-android/4.9/../../../../aarch64-linux-android/bin/ld: cannot find -ldl
collect2: error: ld returned 1 exit status
make: *** [obj/local/arm64-v8a/libhello-jni.so] Error 1

还有有个错误,还是有些文件的权限是不能访问的.
索性直接将整个android-ndk的文件夹的权限全部给修改了

然后就正确的进行了编译.所以如果在linux下编译遇到这种错误的话,要有以下的几点检查:
1:检查文件夹是否有属性,因为ndk-build与sudo是不能连用的
2:修改过文件夹如果还不能的话,那就去检查文件,因为如果源文件中出现一些中文空格等的话,这个时候也是会编译报错的

你可能感兴趣的:(Android学习)