Eclipse之NDK编译——常见异常的解决办法记录

来源:互联网 发布:成都租房知乎 编辑:程序博客网 时间:2024/05/30 05:16

转自http://www.myexception.cn/eclipse/1842938.html

-------------------------------------------------------------------------------

Eclipse之NDK编译——常见错误的解决方法记录

在工程目录下的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

${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

Name的值:streamsize,Value的值:long

添加完成后,点击确定后,错误消失。

0 0
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 狗生完小狗不爰吃饭怎么办 比熊见了狗就叫怎么办 小狗到新主人家里吐怎么办 床上有小绿叶蝉怎么办 腰椎间盘轻微突出怎么办 养的小白兔死了怎么办 小鸡嘴边起很大的疙瘩怎么办 兔子下牙齿断了怎么办 刚种的花蔫了怎么办 鲜切花花朵蔫了怎么办 兔子扭伤脚肿了怎么办 兔子的耳朵肿了怎么办 家里养兔子大了怎么办 幼兔不吃兔粮怎么办 大兔子咬小兔子怎么办 买的小兔子拉稀怎么办 半个月的小兔子怎么办 母兔下崽没奶怎么办 母松鼠下崽后没有奶怎么办 母猫下崽后小猫没奶吃怎么办 母兔产后没奶水怎么办 兔子生崽了不管怎么办 兔子下小兔不管小兔怎么办 兔子下小兔示喂奶怎么办 兔子生完小兔不喂奶怎么办 小兔子生宝宝了怎么办 人摸了小兔崽怎么办 狗狗尿道有脓怎么办 笼养母兔下崽了怎么办 小羊羔站不起来怎么办 兔子不让小兔子吃奶怎么办 兔子不吃东西没精神怎么办 母兔没有初奶怎么办 兔子只喝水不吃东西怎么办 兔子不吃东西也不喝水怎么办 兔子怀孕后不爱吃东西喝水怎么办 母兔产仔无奶怎么办 仔兔十五天母兔没奶怎么办 兔子刚生下兔宝宝该怎么办 兔子不吃草超瘦怎么办 兔子喝水喝多了怎么办