5

I just installed openCV ver. 3.00 beta on my computer and I'm trying to test it with VS2013. I followed quick start guide:

1) Installation for windows, using pre-build libraries.

2) OpenCV inside Microsoft VS, using local method and x64/vc12 directory for libraries.

As a result, their example(listed in link #2) produced an error:

#include <opencv2/core.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui.hpp>
#include <iostream>

using namespace cv;
using namespace std;

int main(int argc, char** argv)
{
    if (argc != 2)
    {
        cout << " Usage: display_image ImageToLoadAndDisplay" << endl;
        return -1;
    }

    Mat image;
    image = imread(argv[1], IMREAD_COLOR); // Read the file

    if (image.empty()) // Check for invalid input
    {
        cout << "Could not open or find the image" << std::endl;
        return -1;
    }

    namedWindow("Display window", WINDOW_AUTOSIZE); // Create a window for display.
    imshow("Display window", image); // Show our image inside it.

    waitKey(0); // Wait for a keystroke in the window
    return 0;
}

The output is:

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

As far as I understand, my program can see openCV libraries, but for some reason cannot open them. Please help.

Thanks

Update: Tried to do what was recommended in first four comments, no result still. So I will post here full information:

Project: CUDA 6.5 (I need to work with CUDA).

Source file: Source.cpp

Mode: Debug, x64.

Enviromental variables:

OPENCV_DIR: C:\programs\misha\opencv\build\x64\vc12

Path (the last string): %OPENCV_DIR%\bin

Page Properties:

C\C++ -> General -> Additional Include Directories(last string):
    $(OPENCV_DIR)\..\..\include
Linker -> General -> Additional Library Directories(last string):
    $(OPENCV_DIR)\lib
Linker -> Input -> Additional Dependencies:
    opencv_calib3d300d.lib
    opencv_core300d.lib
    opencv_features2d300d.lib
    opencv_flann300d.lib
    opencv_highgui300d.lib
    opencv_imgcodecs300d.lib
    opencv_imgproc300d.lib
    opencv_ml300d.lib
    opencv_objdetect300d.lib
    opencv_photo300d.lib
    opencv_shape300d.lib
    opencv_stitching300d.lib
    opencv_superres300d.lib
    opencv_ts300d.lib
    opencv_video300d.lib
    opencv_videoio300d.lib
    opencv_videostab300d.lib

Output:

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

So, I cannot build x64 project for some reason. Error is the same.

Update 2: If you can build this example (or any example with OpenCV), can you please send it on genkin@physics.msu.ru? I will figure it out by myself

Mikhail Genkin
  • 3,247
  • 4
  • 27
  • 47
  • Have you read this? http://answers.opencv.org/question/51060/error-lnk1181-opencv_calib3d300dlib/ – Manav Kataria Jan 20 '15 at 01:00
  • Another Question (Answered) on SO: http://stackoverflow.com/questions/27066754/opencv-3-0-x64-vs2013-error-lnk1104 – Manav Kataria Jan 20 '15 at 01:00
  • Still didn't figured out what should I do, sorry – Mikhail Genkin Jan 20 '15 at 01:13
  • 1
    `x64/vc12` libraries are for 64 bit applications and Visual Studio 2013. You can not use the x64 libraries for the Win32 configuration. You will need the 32 bit versions for that. Build a x64 application or switch to 32 bit libraries. – drescherjm Jan 20 '15 at 01:16
  • Still not working. I posted an update with full information – Mikhail Genkin Jan 20 '15 at 17:01
  • Does `opencv_calib3d300d.lib` exist in this folder `C:\programs\misha\opencv\build\x64\vc12` – drescherjm Jan 20 '15 at 17:13
  • Oh, that might be the issue. All this libraries are in the folder `C:\programs\misha\opencv\build\x64\vc12\staticlib` – Mikhail Genkin Jan 20 '15 at 17:15
  • I tried to include the last path into linker -> general. As a result, a huge amount of errors of the type `Unresolved external symbol` and `error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in Source.obj` – Mikhail Genkin Jan 20 '15 at 17:18
  • Oh I am sorry you have `C:\programs\misha\opencv\build\x64\vc12\lib` as the search path not `C:\programs\misha\opencv\build\x64\vc12` – drescherjm Jan 20 '15 at 17:25
  • That means your runtime settings for your application conflict from the settings for the compiled opencv. I believe you need to set the runtime for your application to Multithreaded debug /MTd not Multithreaded Debug DLL /MDd – drescherjm Jan 20 '15 at 17:27
  • I did it (in C\C++ -> code generation), and (with `C:\programs\misha\opencv\build\x64\vc12\staticlib` included in linker) there are 580 errors instead of 682. – Mikhail Genkin Jan 20 '15 at 17:39
  • @drescherjm, can you send any helloword open_CV project by mail? – Mikhail Genkin Jan 20 '15 at 22:06
  • Since I would have to generate one ( giving you 30+ minutes of my time) I have no time for that. I am under a very important deadline at work. – drescherjm Jan 20 '15 at 22:19
  • Ok, I understand. But why 30 minutes? If u used it before, you can set everything up for 1 minute and build it for 15 sec, and send it as zip for another 30sec – Mikhail Genkin Jan 20 '15 at 22:21
  • So everyone is using openCV in the same regime and it is working? – Mikhail Genkin Jan 22 '15 at 17:48

4 Answers4

4

After a long time of different attempts, I found the answer here. For x64 project, in addition to what I did above, you have to:

1) Restart your PC after setting enviromental variables. Variable Path was not updated on my computer without restart.

2) In addition to libraries added above, you have to add (although, for this example some of them might not be used):

ippicvmt.lib
IlmImfd.lib
libtiffd.lib 
libpngd.lib
libjasperd.lib
libjpegd.lib
libwebpd.lib
zlibd.lib
comctl32.lib

Edit: I recently had to install it again on a new PC. As user1060873 pointed out, you have to add only the libraries located in your $OPENCV$/lib folder. For example, on my PC it is C:\opencv\build\x64\vc12\lib. Note, that for debug mode you should add opencv_world310d.lib, and for release opencv_world310.lib

Community
  • 1
  • 1
Mikhail Genkin
  • 3,247
  • 4
  • 27
  • 47
  • Can I ask where the `opencv_core300d.lib` and other are files located? If you remember. – luckyging3r Feb 21 '17 at 06:09
  • There seems to be an update to how things are done... http://stackoverflow.com/a/30608745/5184092 sort of worked minus `opencv_ts300d.lib`. I am on version `320` and used that instead of `300` now getting a `dll` error that I have to figure out. – luckyging3r Feb 21 '17 at 06:15
4

Unfortunately that solution did not work for me.

I made it work by adding as additional dependencies(Linker -> Input -> Additional Dependencies:) only those libraries located in my $(OPENCV_DIR)\lib folder. Namely: opencv_ts300d.lib;opencv_world300d.lib.

  • You should probably explain *which* solution didn't work, since you can't assume any particular order of answers or even that the other answer will remain. A bit of code formatting (Ctrl-K) would not go amiss either. – Nathan Tuggy Jun 03 '15 at 00:38
1

I'm also facing the same problem. I am using win7 x64 with VS2015 and OpenCV 3.2 After several hours of struggling I finally found out the answer. Each version is not the same, and there may be some differences. So this is what I did :

  1. Find where your libraries are for Additional Library, it is located on $OPENCV$/lib folder
  2. ONLY put those is $OPENCV$/lib folder into the Additional Library (Project properties, Configuration Properties, Linker, Input). In my case I put opencv_world300d.lib (according to official tutorial which is not up to date!) into my Additional Library. But after I check the library folder, there is opencv_world320d.lib, so instead of 300 I write 320.
  • That was what I did wrong too. also check the inheritance values and remove 'opencv_world320d.lib' at my case – M at Sep 21 '17 at 16:20
1

Solved this problem by unchecking the "inherit from parent or project defaults" checkbox under Linker->Input->Additional Dependencies

I added "opencv_world300d.lib" since Im using opencv 3.0.0 build x64 vc11

Kings
  • 11
  • 2