链接预编译的静态库时的链接器错误

时间:2018-06-26 19:54:21

标签: android c++ qt android-ndk linker

我有一个使用Qt库用C ++编写的大型项目,而我还有另一个用Java编写的库。现在,我想编写一个可以同时使用两个库的android应用程序。

因为我不想摆弄android studio中的Qt库(请告诉我是否有更简单的方法),所以我决定为android创建一个静态的qt安装是最简单的,请使用qt creator预编译该项目(将所有依赖项打包在一起),然后将预编译的库导入android studio中。除链接步骤外,其他所有操作均正常。我怀疑这与所有extern "C"的东西有关。

侧面说明:我无法让qt吐出共享的目标文件,但是我设法获得了一个充满对象文件(甚至是Qt的文件)的静态库。

我收到如下链接错误:

../../../../lib/armeabi-v7a/libapi.a(api.o):api.cpp:function IfStreamQIODeviceWrapper::seek(long long): error: undefined reference to 'std::istream::seekg(std::fpos<mbstate_t>)'
../../../../lib/armeabi-v7a/libapi.a(api.o):api.cpp:function TestAPI_loadFile: error: undefined reference to 'QIODevice::QIODevice()'
../../../../lib/armeabi-v7a/libapi.a(api.o):api.cpp:function TestAPI_loadFile: error: undefined reference to 'std::istream::seekg(long long, std::_Ios_Seekdir)'
../../../../lib/armeabi-v7a/libapi.a(api.o):api.cpp:function TestAPI_loadFile: error: undefined reference to 'std::istream::tellg()'

但是libapi.a实际上包含这些符号(根据nm):

nm -C libapi.a|grep -n5 std::istream::seekg

172-         U std::istream::read(char*, int)
173:         U std::istream::seekg(std::fpos<mbstate_t>)
174:         U std::istream::seekg(long long, std::_Ios_Seekdir)
175-         U std::istream::tellg()
176-00000001 W std::_List_base<Ms::SynthesizerGroup, 
std::allocator<Ms::SynthesizerGroup> >::_M_clear()
177-00000001 W std::_List_base<Ms::IdValue, 
std::allocator<Ms::IdValue> >::_M_clear()

因此,它似乎并不仅限于Qt相关的功能,因为我不知何故会收到标准库中应有的链接器错误。知道我想念什么吗?

0 个答案:

没有答案
相关问题