简体   繁体   English

链接时未定义参考-缺少库?

[英]undefined reference when linking - missing libraries?

I am using OpenCV 3.1 for Windows, MinGW, NetBeans. 我正在为Windows,MinGW,NetBeans使用OpenCV 3.1。

According to this there should be just one OpenCV library that integrates multitude of other ones: 据此,应该只有一个OpenCV库可以集成许多其他库:

OpenCV 3.x only contains one lib - opencv_world.lib? OpenCV 3.x仅包含一个库-opencv_world.lib?

I am trying to use the pre-built libraries: 我正在尝试使用预构建的库:

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

Linking: 连结:

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

And I am getting a lot of errors like this: 而且我收到很多这样的错误:

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()'

Something I would expect after not including opencv_core and such - but as I understand they all should be in opencv_world310 now. 在不包括opencv_core之类的东西之后,我会期待一些-但据我所知,它们现在都应该位于opencv_world310中。

How to solve this problem? 如何解决这个问题呢?

You are using OpenCV built with vc14 (Visual Studio 2015) compiler: 您正在使用通过vc14(Visual Studio 2015)编译器构建的OpenCV:

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

You need to rebuild OpenCV with MinGW, and link to it. 您需要使用MinGW重建OpenCV并链接到它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM