Ask Your Question
0

library to link for imread

asked 2017-01-17 02:01:32 -0500

pauldelamusica gravatar image

I am new to opencv. What library should I link for imread? The examples seem to assume one already know.

I build a simple program and I got an error:

error LNK2019: unresolved external symbol "class cv::Mat __cdecl cv::imread(class cv::String const &,int)" (?imread@cv@@YA?AVMat@1@AEBVString@1@H@Z) referenced in function main

I linked the following libs already:

opencv_highgui320d.lib opencv_imgproc320d.lib opencv_core320d.lib libpngd.lib libtiffd.lib zlibd.lib IlmImfd.lib libjasperd.lib libjpegd.lib comctl32.lib gdi32.lib

edit retag flag offensive close merge delete

3 answers

Sort by ยป oldest newest most voted
2

answered 2017-01-17 02:06:27 -0500

LBerger gravatar image

You can use imread doc : imread is here with in link imgcodecs you will need opencv_imgcodecs320.lib

I think you will need core too opencv_core320

edit flag offensive delete link more
1

answered 2017-01-17 02:13:00 -0500

berak gravatar image

unfortunately, this depends on the opencv version, and the compiler you use ;(

for opencv 3.2:

g++, linux: -lopencv_imgcodecs

g++ (mingw): -lopencv_imgcodecs320 (needs version number !)

vs2015 prebuilt: opencv_world320.lib (all libs in one)

vs20xx, self built libs: opencv_imgcodecs320.lib


for opencv2.4.x:

g++: -lopencv_highgui

VS20xx: opencv_highgui2413.lib // needs correct version number !

edit flag offensive delete link more
0

answered 2017-06-08 14:40:10 -0500

If you are using the sample Visual Studio solution from here: https://github.com/GPUOpen-Profession...

There are three projects in this solution, and you need to make sure you trying to add the library reference to the correct project, as each project in the solution has separate properties. runvx is the project you need to edit.

But... You may not actually need to edit it, as you can see it is already setup for linking to $(OpenCV_DIR)\x64\vc12\staticlib

Now. If you are here, two things could have gone wrong.

  1. Did you download the correct version of OpenCV? OpenCV 3.0 contains VC11 and VC12 dlls (Visual Studio 2012 and 2013), while OpenCV 3.2.0 contains only VC14 dlls, which are only for Visual Studio 2015.

  2. Did you add the OpenCV folder to the windows Environmental Variables? If not, press the Windows Key and Pause at the same time. Then select "Advanced System Settings" then "Environmental Variables". You want to look at the lower portion of this screen, titled "System variables" Press "New..." Then Enter: OpenCV_DIR into the Variable Name, and the path to your OpenCV directory into followed by "opencv\build" into the Variable Value.

For more details on step 2. When you download and install the fairly large OpenCV exe, it asks you were you want to extract the data too. This is actually not a location for temporary files, but the actual files you are going to need. So I extracted them to: C:\OpenGL\opencv-3.0. I also have OpenCV 3.2 installed for use with Visual Studio 2015.....although you can only set your Environmental Variable once, so you have to choose which OpenCV version will be "default". With my configuration for Visual Studio 2013, my Environmental Variable Value is: C:\OpenGL\opencv-3.0\opencv\build

A separate note on Visual Studio. Microsoft would very much like you to download Visual Studio 2017 or whatever the current version is, however this usually is not the best idea because you will have to convert solutions built on earlier versions of Visual Studio to your newer version. Also there is a different C++ compiler for each Visual Studio version, and guess what....The DLLs you are trying to work with MUST match the compiler you're trying to use. So even if you upgrade the solution, there is as of 2017-06-08, no version of OpenCV that supports Visual Studio 2017.

In order to download previous version of visual studio, you have to create a free account with microsoft. You can sign up using this link, and after you are logged in, visit this link: https://www.visualstudio.com/vs/older...

Then select "Downloads" from the menu. In the search box type "Visual Studio Community 2013". For me there was only one result, "Visual Studio Community 2013 with Update 5" (Release date 11/13/2015) You can repeat these steps for "Visual Studio Community 2015" if you are interested in using OpenCV 3.2.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2017-01-17 02:01:32 -0500

Seen: 7,700 times

Last updated: Jan 17 '17