Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenCV error: "LINK : fatal error LNK1104: cannot open file 'opencv_core231d.lib' "

I'm trying to compile a simple code in visual studio + opencv, but got this error.

Code:

#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>

using namespace cv;

int main ( int argc, char **argv )

{
    Mat im_gray;
    Mat img_bw;
    Mat img_final;

    Mat im_rgb  = imread("001.jpg");
    cvtColor(im_rgb,im_gray,CV_RGB2GRAY);

    adaptiveThreshold(im_gray, img_bw, 255, ADAPTIVE_THRESH_MEAN_C, THRESH_BINARY_INV, 105, 1); 

    imwrite("001-bw2.jpg", img_final);
    return 0;
}  

Output:

1>------ Build started: Project: pibiti, Configuration: Debug Win32 ------
1>LINK : fatal error LNK1104: cannot open file 'opencv_core231d.lib'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

The Linker >> Input:

opencv_core231d.lib
opencv_highgui231d.lib
opencv_video231d.lib
opencv_ml231d.lib
opencv_legacy231d.lib
opencv_imgproc231d.lib
tbb_debug.lib
tbb_preview_debug.lib
tbbmalloc_debug.lib
tbbmalloc_proxy_debug.lib
tbbproxy_debug.lib

How can I fix this? the file 'opencv_core231d.lib' is already there, why this error?

like image 373
U23r Avatar asked Feb 13 '14 03:02

U23r


3 Answers

Add the path of the library files to the library path.

Right click the project and go to Properties->Linker->Additional Library directories. Add the path to this list.

like image 128
littleimp Avatar answered Oct 23 '22 18:10

littleimp


Adding to this list of solutions, mine was simply to change the project to 64 bit.

like image 44
Tim Harding Avatar answered Oct 23 '22 18:10

Tim Harding


I had the same issue. Despite ensuring that the path to the libraries was correct, I was getting a "Cannot open file" error. The issue was I had named the dlls wrong in additional assembly references in Linker Properties. I had given them as above(with "231" at end). But the names of the actual Dlls were ending with "249". Changing that solved my issue. Might be helpful to others :-)

After this, project will get built successfully. But you can expect a run time error that opencv_core249d.lib is missing in your computer, you need to re-install it. That is becuase even though the path has been added to environment variables, windows has to be restarted to have it in effect. This will solve it.

like image 2
Sreeraj Avatar answered Oct 23 '22 19:10

Sreeraj