使用C ,未定义的参考设置OpenAlpr

Setting up OpenALPR with c++, undefined reference.

本文关键字:参考 设置 OpenAlpr 未定义 使用      更新时间:2023-10-16

我需要将OpenAlpr库集成到我的C 程序中。不幸的是,我无法链接工作。

openalpr.lib 在c: path to alpr, alpr.h 标题c: path path to alpr include *.dll文件在带有 main 文件的目录中。系统Windows7,编译器GCC 5.3。

当前构建命令:

g++ -Wall -fexceptions -g -IC:pathtoalprinclude -c C:pathtoprojectmain.cpp -o objmain.o
g++ -LC:pathtoalpr -o bintest.exe objmain.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> >)'

等等,等等,等等,许多类似的"未定义参考"。

OpenAlpr库以二进制版本从以下方式下载:https://github.com/openalpr/openalpr/wiki/compilation-instructions-(Windows)

我应该从来源构建库吗?也许我错过了什么?预先感谢。

gcc5和c 11 abi:

依靠仍然使用旧ABI的第三方库或插件接口的用户可以使用-D_GLIBCXX_USE_CXX11_ABI=0构建其代码,并且一切都可以正常工作。在大多数情况下,由于链接器的错误抱怨涉及__cxx11的未解决的符号。

,这将是显而易见的。

尝试使用-D_GLIBCXX_USE_CXX11_ABI=0