使用NDK编译的时候出现 undefined reference to
2014-05-30 17:30
465 查看
最近一段时间在使用NDK进行编译的时候一直出现undefined reference to的问题
代码写的没有问题, 在visual studio中也能找到定义, 可是在NDK中就是出现这个问题过不去.
使用nm, objdump 查看.o文件也是发现就是那几个函数未定义;
多番GOOGLE之下 找到了问题所在
解决问题: 在android.mk中加入 LOCAL_ALLOW_UNDEFINED_SYMBOLS := true
引用:>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Add the line
LOCAL_ALLOW_UNDEFINED_SYMBOLS := true
to the Android.mk file and it should work. As explained in the ndk doc, it is because the ndk performs a debug checking even for avoiding runtime linking error and for some motivations it doesn't find the correct references in a pre-built library. Hope
it coulds help.
http://stackoverflow.com/questions/7209971/ndk-build-undefined-reference-to-errors-when-statically-linking-to-libxml-a
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
PS:
Android.mk文件来向NDK编译系统描述你的源代码
Application.mk文件向NDK编译系统描述你的应用程序需要的原生代码。
objdump -j .text -Sl objtest | more
-S 尽可能反汇编出源代码,尤其当编译的时候指定了-g这种调试参数时,
效果比较明显。隐含了-d参数。
-l 用文件名和行号标注相应的目标代码,仅仅和-d、-D或者-r一起使用
使用-ld和使用-d的区别不是很大,
代码写的没有问题, 在visual studio中也能找到定义, 可是在NDK中就是出现这个问题过不去.
使用nm, objdump 查看.o文件也是发现就是那几个函数未定义;
多番GOOGLE之下 找到了问题所在
解决问题: 在android.mk中加入 LOCAL_ALLOW_UNDEFINED_SYMBOLS := true
引用:>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Add the line
LOCAL_ALLOW_UNDEFINED_SYMBOLS := true
to the Android.mk file and it should work. As explained in the ndk doc, it is because the ndk performs a debug checking even for avoiding runtime linking error and for some motivations it doesn't find the correct references in a pre-built library. Hope
it coulds help.
http://stackoverflow.com/questions/7209971/ndk-build-undefined-reference-to-errors-when-statically-linking-to-libxml-a
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
PS:
Android.mk文件来向NDK编译系统描述你的源代码
Application.mk文件向NDK编译系统描述你的应用程序需要的原生代码。
nm输出字符 | 含义 |
R | Read only symbol. 比如在代码中有一个const MAXDATA = 3095; 则MAXDATA就是一个Read only symbol |
N | 这是一个调试符号 |
D | 这是一个已经初始化的变量的符号。比如代码中int i = 1和char *str = "Hello"则i和str都是这种类型的符号 |
T | Text段的符号。子程序都是这种符号,比如文件中实现了一个函数function,则function就是这种符号 |
U | 未定义的符号。如果文件中引用了不存在的函数,则这些未定义的函数符号就是这种类型 |
S | 未初始化的符号,比如全局变量int s;则s的符号就是此类型 |
-S 尽可能反汇编出源代码,尤其当编译的时候指定了-g这种调试参数时,
效果比较明显。隐含了-d参数。
-l 用文件名和行号标注相应的目标代码,仅仅和-d、-D或者-r一起使用
使用-ld和使用-d的区别不是很大,
相关文章推荐
- 使用NDK编译的时候出现 undefined reference to
- 使用NDK编译的时候出现 undefined reference to
- 使用NDK编译的时候出现 undefined reference to
- 使用NDK编译的时候出现 undefined reference to
- 使用NDK编译的时候出现 undefined reference to
- 使用NDK编译的时候出现 undefined reference to
- 解决使用NDK进行编译时出现undefined reference to function的问题
- cocos2d-x 使用ndk编译 x86 出现 in function Curl_resolv_timeout: undefined reference to 'sigsetjmp' 错误
- NiosII timestamp使用时编译出现undefined reference to `alt_timestamp问题
- Libcurl使用OpenSSL编译出现undefined reference to `COMP_CTX_free'错误备忘
- QT 编译的时候出现 undefined reference to `vtable for XXX '
- Android之ndk编译出现"undefined reference to method"解决办法
- 使用g++编译C/C++程序,链接时出现undefined reference to错误
- Android NDK 编译时候出现 undefined reference to `__android_log_print
- 使用QtService接口的时候出现undefined reference to `::staticMetaObject'
- 关于arm-linux-gcc交叉编译工具链,实现自己的crt0或者编译UBOOT出现undefined reference to `__aeabi_unwind_cpp_pr0'的解决方法
- 用gcc编译.cpp文件可能出现"undefined reference to `__gxx_personality_v0'"问题的解决
- 关于android底层库编译出现“undefined reference to `__android_log_print'”的解决方法
- 用gcc编译.cpp文件可能出现"undefined reference to `__gxx_personality_v0'"问题的解决
- 编译什么时候出现Undefined reference to 的错误