链接时未定义的引用 - 缺少库?

undefined reference when linking - missing libraries?

我正在为 Windows、MinGW、NetBeans 使用 OpenCV 3.1。

据此,应该只有一个 OpenCV 库集成了许多其他库:

我正在尝试使用预建库:

http://docs.opencv.org/3.0-beta/doc/tutorials/introduction/windows_install/windows_install.html#windowssetpathandenviromentvariable

链接:

g++ -o dist/Release/MinGW-Windows/program_name build/Release/MinGW-Windows/main.o -L../../../lib/opencv/build/x64/vc14/lib -lopencv_world310

而且我遇到了很多这样的错误:

build/Release/MinGW-Windows/main.o:main.cpp:(.text+0x18b): undefined reference to `cv::imread(cv::String const&, int)'
build/Release/MinGW-Windows/main.o:main.cpp:(.text+0x1a0): undefined reference to `cv::String::deallocate()'

在不包括 opencv_core 等之后我期望的东西 - 但据我了解,它们现在都应该在 opencv_world310 中。

如何解决这个问题?

您正在使用由 vc14(Visual Studio 2015)构建的 OpenCV 编译器:

L../../../lib/opencv/build/x64/vc14/lib

您需要使用 MinGW 重建 OpenCV,link。