c++ - 对 `cvCreateBGCodeBookModel' 的 undefined reference

标签 c++ linux opencv

我在编译 C++ 代码时收到错误消息。

$g++ basic100.cpp -o test -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_objdetect
/tmp/ccWqj7E2.o: In function `main':
basic100.cpp:(.text+0x67): undefined reference to `cvCreateBGCodeBookModel'
basic100.cpp:(.text+0x2c6): undefined reference to `cvBGCodeBookUpdate'
basic100.cpp:(.text+0x31d): undefined reference to `cvBGCodeBookClearStale'
basic100.cpp:(.text+0x374): undefined reference to `cvBGCodeBookDiff'
basic100.cpp:(.text+0x3c8): undefined reference to `cvSegmentFGMask'
collect2: error: ld returned 1 exit status

代码在我 friend 的笔记本电脑上运行良好。 我的系统是 32 位 Linux Mint,而他们有 64 位 Ubuntu 14.04。

我 friend 笔记本上使用的编译命令 $ g++ -o fff basic100.cpp pkg-config --cflags --libs opencv

这就是我使用 cvCreateBGCodeBoolModel() 的方式

(model definition :CvBGCodeBookModel* model = 0;//outside main())

    model = cvCreateBGCodeBookModel();

最佳答案

当我运行命令时

grep cvCreateBGCodeBookModel /usr/lib/x86_64-linux-gnu/libopencv_*.so

我得到了结果

Binary file /usr/lib/x86_64-linux-gnu/libopencv_legacy.so matches

所以我假设您在编译中缺少 -lopencv_legacy 标志。但是我有一个 64 位系统。

你能检查一下是否有效吗?

关于c++ - 对 `cvCreateBGCodeBookModel' 的 undefined reference ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30590396/

相关文章:

linux - 创建一个 bash 脚本,为文件中的每个名称创建一个文件夹

linux - Raspberry PI远程调试GTK错误

opencv - 我可以在微 Controller 上使用眼睛检测 opencv 代码吗?

opencv - 无法安装 OpenCV

c++ - 如何将矩阵映射到某个整数值?

模板声明中省略了 C++ 类型参数。但是,在成员函数的定义中又如何呢?

C++ 智能指针地址

c++ - 如果涉及委托(delegate),C++ 中的 RVO 和查询结果作为对象或更好地通过引用传递

linux - 在 Linux 上分发软件?

windows - 跨平台的 OpenCV 视频