0
votes

I am using OpenCV 2.4.5 with a Visual C++ project in the Visual Studio 2012 IDE. My project works correctly in DEBUG mode, but in RELEASE mode, I get the following compile error:

error LNK1181: cannot open input file 'opencv_core245.lib'

I then installed OpenCV and set up the environment variables as follows:

  1. Created the following System Variable: OPENCV_BUILD with the path C:\opencv\build\
  2. Added the following to the Path variable: C:\opencv\build\x86\vc11\bin

Then, in Visual Studio 2012, I created a new property sheet for the debug mode as follows:

Clicked View >> Property Manager Right clicked Debug >> Add New Project Property Sheet

I then edited the property sheet as follows:

C/C++ >> General >> Additional Include Directories: $(OPENCV_BUILD)\include;%(AdditionalIncludeDirectories)

Linker >> General >> Additional Library Directories: $(OPENCV_BUILD)\x86\vc11\lib;%(AdditionalLibraryDirectories)

Linker >> Input >> Additional Dependencies: opencv_core245d.lib;opencv_imgproc245d.lib;opencv_highgui245d.lib;opencv_ml245d.lib;opencv_video245d.lib;opencv_features2d245d.lib;opencv_calib3d245d.lib;opencv_objdetect245d.lib;opencv_contrib245d.lib;opencv_legacy245d.lib;opencv_flann245d.lib;%(AdditionalDependencies)

I followed the same procedure to create a new property sheet for the release mode (I also followed the same procedure for editing the project properties), but for Linker >> Input >> Additional Dependencies I omitted the "d" from each .lib filename (for example opencv_core245.lib instead of opencv_core245d.lib).

In my code, I usually include the files as follows: #include <opencv2\highgui\highgui.hpp>

As I mention earlier, everything works fine in DEBUG mode, but in RELEASE mode I get the following compile error:

error LNK1181: cannot open input file 'opencv_core245.lib'

I've read so many other posts on this forum, but nothing seems to work. Can someone please help me, I am really desperate.

6

6 Answers

0
votes

You can first try going to View-> Property Pages -> Configuration Properties -> Linker -> Input

Under additional dependencies add the 'opencv_core245.lib'

If it doesn't work, try adding all the directory to the .dll or .libs you have included in "Linker, Input" into the "linker, general, additional library directory."

Let me know how it goes. Cheers! (:

0
votes

Ok, I used to have this problem too actually. I thought my above answer could be the solution. It wasn't easy to find, but I managed to hunt down the tutorial video that help me solve this same problem I had in the past.

Here's the video: http://www.youtube.com/watch?v=cgo0UitHfp8

Hope this helps, once again, let me know how it goes (:

0
votes

I just tried to answer a related question at answers.opencv.org.

http://answers.opencv.org/question/11766/release-mode-error-c1083-cannot-open-include-file/?answer=25829#post-id-25829

Briefly, there might be a bug in VS2012, when dealing with broken property files. Try to rebuild your property files.

0
votes

I had exactly the same problem as described into detail in comments in http://answers.opencv.org/question/11766/release-mode-error-c1083-cannot-open-include-file/?answer=25829#post-id-25829 and none of the suggested ideas seemed to work. I think there is some problem with set up of property sheets for release mode, so instead of making new property sheet I imported property sheet from debug mode, but changing the Linker->Additional Libraries to release version without d in name. I have no idea why, but release mode started to work.

0
votes

I used to have the same problem when i started out with opencv.in visual studio,when you look at property manager,there is debug|win32 debug|x64 release|win32 and release|x64,if your machine architecture is x64 and you have set the properties in the property sheets with x64, you should make sure that the property-sheet is added to release|x64 and not release|win32.

if your machine architecture is x86 and you have set the properties in the property sheets with x86, you should make sure that the propertysheet is added to release|win32 and not release|x64. hope that helps

0
votes

After switching to release mode, you must re-specify all the links to folders and libraries in the (release mode) project properties.