2017-09-04 38 views
1

我需要将OpenALPR库集成到我的C++程序中。不幸的是,我不能做链接工作。用C++,未定义的参考设置OpenALPR。

openalpr.lib是在C:\路径\到\ ALPR,alpr.h头在C:\路径\到\ ALPR \包括所有* .dll文件是在产品目录中与文件。 系统Windows7,编译器Gcc 5.3。

当前构建命令:

g++ -Wall -fexceptions -g -IC:\path\to\alpr\include -c C:\path\to\project\main.cpp -o obj\main.o 

g++ -LC:\path\to\alpr -o bin\test.exe obj\main.o -lopenalpr 

代码:

#include <alpr.h> 
int main() 
{ 
    alpr::Alpr openalpr("us", "openalpr.conf"); 
    return 0; 
} 

错误:

undefined reference to `alpr::Alpr::Alpr(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)' 

等等,等等,很多类似的 '未定义的引用' 的。 https://github.com/openalpr/openalpr/wiki/Compilation-instructions-(Windows)

我应该建立从资源库:

OpenALPR库中的二进制版本下载下来?也许我错过了什么?提前致谢。

回答

0

GCC5 and the C++11 ABI

Users that depend on third-party libraries or plugin interfaces that still use the old ABI can build their code with -D_GLIBCXX_USE_CXX11_ABI=0 and everything should work fine. In most cases, it will be obvious when this flag is needed because of errors from the linker complaining about unresolved symbols involving __cxx11 .

尝试用-D_GLIBCXX_USE_CXX11_ABI=0编译。

+0

'克++ -Wall -fexceptions -D_GLIBCXX_USE_CXX11_ABI = 0 -g -IC:\ ALPR \包括-c C:\项目\ main.cpp中-o OBJ \ main.o' 没什么改变。 – Rajju

+0

@Rajju您是否尝试过使用该命令编译后尝试链接? –

+0

是的,我删除.o文件,从头开始编译所有东西,然后再次链接(即使传递-D_GLIBCXX_USE_CXX11_ABI = 0作为链接器标志也是如此)。 – Rajju