Ask Your Question

errors building opencv with visual studio 2013

asked 2014-03-06 16:03:25 -0500

jossyy gravatar image

updated 2014-03-06 16:10:16 -0500

unxnut gravatar image


I searched my problem here, but I dont find a specific solution for my problem. I run the below code, it is ok

int main(int argc, _TCHAR* argv[])
    cv::Mat img();  
    return 0;

but I run the below code, it is failed.

int main(int argc, _TCHAR* argv[])
    Mat img = imread("deneme.png", 1);
    //imshow("opencv Window", img);
    return 0;

The error is : unresolved external. Could you help me please?

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2014-03-06 16:13:09 -0500

unxnut gravatar image

updated 2014-03-06 16:13:58 -0500

You probably did not add the highgui library in the linker. Go to project settings, check for linker, and add the highgui library based on the OpenCV distribution that you have. If you are running OpenCV 2.4.8, it would probably be opencv_highgui248d.lib. And in case you have not, please also add opencv_core248d.lib.

edit flag offensive delete link more


I hope that I do it, my lib is opencv_core244d.lib . I am beginner opencv. Maybe I did it in a wrong path. Could you tell me true path?

jossyy gravatar imagejossyy ( 2014-03-06 16:22:04 -0500 )edit

I tried it properties -> Linker -> General , it is true?

jossyy gravatar imagejossyy ( 2014-03-06 16:30:57 -0500 )edit

You will need to specify the location of library files in your system. Do that in Project->Properties->Linker->General->Additional Library Directories. The libraries are specified in Project->Properties->Linker->Input->Additional Dependencies. I'll suggest that you find the location of your libraries by doing a search in Windows and specifying that in your project properties.

unxnut gravatar imageunxnut ( 2014-03-06 16:31:44 -0500 )edit

I did it , but there is same error :(

jossyy gravatar imagejossyy ( 2014-03-06 16:41:39 -0500 )edit

The problem is solved! Thanks unxhut...

jossyy gravatar imagejossyy ( 2014-03-06 17:28:18 -0500 )edit

answered 2014-04-19 15:47:47 -0500

Y Simson gravatar image

I to had a lot of problems compiling OpenCV on my computer with visual studio 2013. Here are general guidelines I wrote. If I missed something please add to it:


A) 64 vs 32 bit conflicts Make sure the $OPENCV_DIR refers to the right version

For example you have two alternatives in OpenCV 2.4.8:
1) D:\OpenCV\opencv\build\x86\vc11     (32 bits)
2) D:\OpenCV\opencv\build\x64\vc11     (64 bits)

Make sure that your project definition is suited to the right bittage.

How can you check/correct this?
-Right click on solution->properties->Configuration Properties->Platform
-Choose either 64/32 bits depending on what you want

How to define $OPENCV_DIR?
click on start -> Right click on "Computer" -> Properties -> Advanced System setting -> Choose "Advanced" tab -> Environment Variables -> Click on "New..." under System Variables -> For Variable Name enter: OPENCV_DIR -> For Variable Value enter relevant build directory.

B) Including header directory: Make sure to add to the configuration Properties of the project: C++->General->Include Additional Directories->$(OPENCV_DIR)....\include

C) Add OpenCV bin folder to: Linker->General->Additional Library Directories->$(OPENCV_DIR)\lib;

D) Add libs's to: Linker->Input->Additional Dependencies->

For debug copy and paste:

For release copy and paste:

E) For runtime make sure that you have the right DLL folder in your Path: e.g. %OPENCV_DIR%\bin

edit flag offensive delete link more


I am sorry for I am late. I watched a video , I sent it you..

jossyy gravatar imagejossyy ( 2014-04-27 07:40:34 -0500 )edit

Question Tools


Asked: 2014-03-06 16:03:25 -0500

Seen: 816 times

Last updated: Apr 19 '14