Android之 Eclipse NDK编译——常见错误的解决方法记录
2016-06-06 18:36
821 查看
在工程目录下的jni文件夹下编写的c/c++代码在编译时,通常会遇到如下的几种类型错误:
1、Unresolved inclusion:<XXX>
2、syntax error
3、Function 'XXX' could not be resolved
4、Type 'XXX' could not be resolved
5、Symbol 'XXX' could not be resolved
6、Method 'XXX' could not be resolved
7、Invalid arguments 'Candidates are: ...'
错误原因:
大多数情况是因为相关头文件没有加入导致,也有一些是因为一些参数无效导致的(当然无效参数也可能是因为头文件未加入,见下述)。
相关错误解决方法——添加头文件:
错误内容一:
1、Unresolved inclusion: <jni.h>、Unresolved inclusion: <stdio.h>、Unresolved inclusion: <malloc.h>、Unresolved inclusion: <android/log.h>、...
2、Function '__android_log_print' could not be resolved、Type 'JNIEnv' could not be resolved、Type 'jstring' could not be resolved、Type
'jclass' could not be resolved、Function 'malloc' could not be resolved、Function 'memcpy' could not be resolved、Method 'FindClass' could not be resolved、Type 'jsize' could not be resolved、Symbol 'NULL' could not be resolved、...
解决方法:
右击项目 --> Properties --> 左侧C/C++ General --> Paths and Symbols --> 右侧Includes --> GNU C++(.cpp) --> Add
| __>GNU C(.c) __|
${NDKROOT}\platforms\android-18\arch-arm\usr\include
错误内容二:
1、Unresolved inclusion: <iostream>、Unresolved inclusion: <fstream>、Symbol 'std' could not be resolved、..
2、Type 'fstream' could not be resolved、Symbol 'in' could not be resolved、Method 'seekg' could not be resolved、Method 'read'
could not be resolved、...
解决方法:
添加路径(步骤见上述解决方法):
${NDKROOT}\sources\cxx-stl\gnu-libstdc++\4.8\include 、${NDKROOT}\sources\cxx-stl\gnu-libstdc++\4.8\libs\armeabi\include
错误内容三:
Invalid arguments 'Candidates are:void * malloc(?)'、Invalid arguments 'Candidates are:void * memcpy(void *, const void *,
?)'
解决方法:
添加路径(步骤见上述解决方法):
${NDKROOT}\toolchains\arm-linux-androideabi-4.8\prebuilt\windows\lib\gcc\arm-linux-androideabi\4.8\include
相关错误解决方法——符号替换:
有时编译时会遇到这样的错误提示:Invalid arguments 'Candidates are:std::basic_istream<char,std::char_traits<char>> & read(char *, ?)',尽管我们添加了相应的头文件,但仍然有无效参数这样的错误,错误提示中的‘?’表示无效参数。
碰到这类错误,可以索引到对应函数(ctrl+点击该函数)read,查看函数定义中的参数类型,此函数索引到的头文件中的参数类型为streamsize,但使用时用到的long。
解决方法:
右击项目 --> Properties --> 左侧C/C++ General --> Paths and Symbols --> 右侧Symbols --> GNU C++(.cpp) --> Add
| __>GNU C(.c) __|
Name的值:streamsize,Value的值:long
添加完成后,点击确定后,错误消失。
感谢http://android.662p.com/thread-6201-1-1.html
1、Unresolved inclusion:<XXX>
2、syntax error
3、Function 'XXX' could not be resolved
4、Type 'XXX' could not be resolved
5、Symbol 'XXX' could not be resolved
6、Method 'XXX' could not be resolved
7、Invalid arguments 'Candidates are: ...'
错误原因:
大多数情况是因为相关头文件没有加入导致,也有一些是因为一些参数无效导致的(当然无效参数也可能是因为头文件未加入,见下述)。
相关错误解决方法——添加头文件:
错误内容一:
1、Unresolved inclusion: <jni.h>、Unresolved inclusion: <stdio.h>、Unresolved inclusion: <malloc.h>、Unresolved inclusion: <android/log.h>、...
2、Function '__android_log_print' could not be resolved、Type 'JNIEnv' could not be resolved、Type 'jstring' could not be resolved、Type
'jclass' could not be resolved、Function 'malloc' could not be resolved、Function 'memcpy' could not be resolved、Method 'FindClass' could not be resolved、Type 'jsize' could not be resolved、Symbol 'NULL' could not be resolved、...
解决方法:
右击项目 --> Properties --> 左侧C/C++ General --> Paths and Symbols --> 右侧Includes --> GNU C++(.cpp) --> Add
| __>GNU C(.c) __|
${NDKROOT}\platforms\android-18\arch-arm\usr\include
错误内容二:
1、Unresolved inclusion: <iostream>、Unresolved inclusion: <fstream>、Symbol 'std' could not be resolved、..
2、Type 'fstream' could not be resolved、Symbol 'in' could not be resolved、Method 'seekg' could not be resolved、Method 'read'
could not be resolved、...
解决方法:
添加路径(步骤见上述解决方法):
${NDKROOT}\sources\cxx-stl\gnu-libstdc++\4.8\include 、${NDKROOT}\sources\cxx-stl\gnu-libstdc++\4.8\libs\armeabi\include
错误内容三:
Invalid arguments 'Candidates are:void * malloc(?)'、Invalid arguments 'Candidates are:void * memcpy(void *, const void *,
?)'
解决方法:
添加路径(步骤见上述解决方法):
${NDKROOT}\toolchains\arm-linux-androideabi-4.8\prebuilt\windows\lib\gcc\arm-linux-androideabi\4.8\include
相关错误解决方法——符号替换:
有时编译时会遇到这样的错误提示:Invalid arguments 'Candidates are:std::basic_istream<char,std::char_traits<char>> & read(char *, ?)',尽管我们添加了相应的头文件,但仍然有无效参数这样的错误,错误提示中的‘?’表示无效参数。
碰到这类错误,可以索引到对应函数(ctrl+点击该函数)read,查看函数定义中的参数类型,此函数索引到的头文件中的参数类型为streamsize,但使用时用到的long。
解决方法:
右击项目 --> Properties --> 左侧C/C++ General --> Paths and Symbols --> 右侧Symbols --> GNU C++(.cpp) --> Add
| __>GNU C(.c) __|
Name的值:streamsize,Value的值:long
添加完成后,点击确定后,错误消失。
感谢http://android.662p.com/thread-6201-1-1.html
相关文章推荐
- Android NDK 开发教程
- android.mk用法
- JNI由浅入深
- Android JNI入门搭建环境(一)
- Android JNI中的常用方法
- Android ndk 编译问题解决方法
- Android NDK 学习笔记
- Android NDK Cocos2dx 3.4 Label中文显示
- NDK-jni error for android
- Android JNI 技术简介
- Android build system & Android.mk 规范
- cygwin下配置android-ndk时遇到的各种问题及解决方案
- Windows环境下Android NDK环境搭建
- Windows环境下Android NDK环境搭建
- coco2d-x环境搭建及编译(一)
- android ndk_r10 下载
- Android下用OpenCV3.0库静态链接错误解决方法
- cocos2d-x环境搭建及android移植
- 面向英特尔® 架构 (IA) 创建和移植基于 NDK 的 Android* 应用
- Android NDK编译