且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

由于未定义的引用,无法获取OpenCV进行编译?

更新时间:2021-07-25 16:12:42

这是一个链接器问题。尝试:

This is a linker issue. Try:

g++ -o test_1 test_1.cpp `pkg-config opencv --cflags --libs`

这应该可以编译源代码。但是,如果您最近从源编译OpenCV,您将在运行时遇到链接问题,将不会找到库。
在大多数情况下,在从源代码编译库之后,您需要最后执行:

This should work to compile the source. However, if you recently compiled OpenCV from source, you will meet linking issue in run-time, the library will not be found. In most cases, after compiling libraries from source, you need to do finally:

sudo ldconfig