0

I installed opencv 3.0 in my windows10 64 bit. I created a C++ project in visual studio community 2017 and did all these steps provided in opencv documentation (local method in this link which are: 1- creation of environment variable:

OPENCV_DIR C:\Program Files\opencv\build\x86\vc11

With I added in user and system Path as follow

%OPENCV_DIR%\bin

2- In my project I added in Properties -> C/C++ -> additional include repositories:

C:\Program Files\opencv\build\include

3- Properties -> Link -> General:

$(OPENCV_DIR)\lib
$(OPENCV_DIR)\staticlib

I included staticlib because at first the compiler didn't find opencv_core300d.lib while this one exists in staticlib, so I added it.

checked YES for use library dependency entries

4- Properties -> Link -> Entry:

opencv_core300d.lib
opencv_highgui300d.lib
opencv_imgproc300d.lib
opencv_ml300d.lib
opencv_ts300d.lib

with Herited values:

kernel32.lib
user32.lib
gdi32.lib
winspool.lib
comdlg32.lib
advapi32.lib

I got more 800 errors all related to mismatch between values in .obj files related to opencv_core300d.lib:

    1>Source.cpp
1>opencv_core300d.lib(alloc.obj) : error LNK2038: discordance détectée pour '_MSC_VER' : la valeur '1700' ne correspond pas à la valeur '1900' in Source.obj
1>opencv_core300d.lib(alloc.obj) : error LNK2038: discordance détectée pour 'RuntimeLibrary' : la valeur 'MTd_StaticDebug' ne correspond pas à la valeur 'MDd_DynamicDebug' in Source.obj
1>opencv_core300d.lib(stl.obj) : error LNK2038: discordance détectée pour '_MSC_VER' : la valeur '1700' ne correspond pas à la valeur '1900' in Source.obj
1>opencv_core300d.lib(stl.obj) : error LNK2038: discordance détectée pour 'RuntimeLibrary' : la valeur 'MTd_StaticDebug' ne correspond pas à la valeur 'MDd_DynamicDebug' in Source.obj
1>opencv_core300d.lib(matrix.obj) : error LNK2038: discordance détectée pour '_MSC_VER' : la valeur '1700' ne correspond pas à la valeur '1900' in Source.obj
1>opencv_core300d.lib(matrix.obj) : error LNK2038: discordance détectée pour 'RuntimeLibrary' : la valeur 'MTd_StaticDebug' ne correspond pas à la valeur 'MDd_DynamicDebug' in Source.obj
1>opencv_core300d.lib(opencv_core_pch.obj) : error LNK2038: discordance détectée pour '_MSC_VER' : la valeur '1700' ne correspond pas à la valeur '1900' in Source.obj
1>opencv_core300d.lib(opencv_core_pch.obj) : error LNK2038: discordance détectée pour 'RuntimeLibrary' : la valeur 'MTd_StaticDebug' ne correspond pas à la valeur 'MDd_DynamicDebug' in Source.obj
1>opencv_core300d.lib(system.obj) : error LNK2038: discordance détectée pour '_MSC_VER' : la valeur '1700' ne correspond pas à la valeur '1900' in Source.obj

I tried to resolve the issue by checking similar answers to similar errors and according to this answer it's due to different versions of the compiler. If so, how to correct it?

Sample code used to test that opencv works:

    #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;
}

I need help! Thank you.

SarahData
  • 769
  • 1
  • 12
  • 38
  • Was opencv built with Visual Studio 2017 or at least 2015? Is this for the Debug configuration. `opencv_core300d.lib` will not work for a release build. – drescherjm Jul 27 '17 at 20:40
  • Why 3.0 when 3.2 has been available since last december? Did you build your own copy? It's unlikely that a package from 2015 would have been built with a few months old compiler. – Dan Mašek Jul 27 '17 at 20:41
  • 2
    You are trying to link a library which was compiled with different version of the compiler (at least that is the error with `_MSC_VER`) in [wikipedia](https://en.wikipedia.org/wiki/Microsoft_Visual_C%2B%2B#Internal_version_numbering) you can see the versions used... in your case one is compiled with Visual Studio 2013 compiler and the other one with 2015. The other error is that you are compiling it with a diiferent flag (static debug vs dynamic debug) look at [this](https://stackoverflow.com/questions/16830842/using-static-libraries-instead-of-dynamic-libraries-in-opencv) for a solution – api55 Jul 27 '17 at 20:42
  • 1
    ***la valeur '1700' ne correspond pas à la valeur '1900'*** This means you are mixing compiler versions. I can't read this language but I still understand enough by the english error message for the same error. – drescherjm Jul 27 '17 at 20:43
  • You can not use the binaries you have with Visual Studio 2017. You need to either build (using the source code) or download a version of opencv that is compatible with your compiler. – drescherjm Jul 27 '17 at 20:57
  • @drescherjm it's in Debug. From where could have come these different versions of the compiler? I know it's due to mixing compiler versions as I found in other answers of the same type of error but I didn't know how to correct it! Note: I'm a starter with dev using Visual Studio. – SarahData Jul 27 '17 at 20:58
  • Your opencv binaries are from an older version of Visual Studio. You can not use these with your current version of Visual Studio. There is no setting you can do to make your current binaries work (well without installing the older compiler and using its toolset in Visual Studio 2017). – drescherjm Jul 27 '17 at 20:59
  • Does it mean that opencv 3.0 does not work with Visual Studio 2017? – SarahData Jul 27 '17 at 21:03
  • ***Does it mean that opencv 3.0 does not work with Visual Studio 2017?*** It may be possible to compile opencv 3.0 from source in Visual Studio 2017 and produce binaries that will work. You just can not use the ones you have. Your best bet is to use a newer version of opencv. – drescherjm Jul 27 '17 at 21:04
  • What do you mean by "from source" = from opencv official download link? Thank you for your help! – SarahData Jul 27 '17 at 21:09
  • You can download the source code at the opencv web page or github https://github.com/opencv/opencv – drescherjm Jul 27 '17 at 21:20
  • There are 52 releases you can download the source code for: https://github.com/opencv/opencv/releases – drescherjm Jul 27 '17 at 21:21
  • 1
    I can see from the filename that opencv-3.2 binaries support your compiler. vc14 is compatible with Visual Studio 2015 and 2017. – drescherjm Jul 27 '17 at 21:22

1 Answers1

0

These error is due to different build version of the opencv library. You can download the pre build binaries for your compiler version if available or else you need to build OpenCV from source using cmake. In your case you require binaries built for vs2017 i.e. _MSC_VER 1900.

AdityaIntwala
  • 2,536
  • 1
  • 17
  • 17
  • I wanted to go back to visual studio community 2015 to avoid any future problem (I thought maybe 2017 is too new so there is probably some problems) but didn't find any link to download it. – SarahData Jul 28 '17 at 14:48
  • 1
    ***I wanted to go back to visual studio community 2015 to avoid any future problem*** That would not fix the issue either. VS 2015 and VS 2017 are binary compatible with each other but not compatible with any other version of Visual Studio. – drescherjm Jul 28 '17 at 22:08