0
votes

Their is a problem with the Linker for C++ in my Visual Studios 2013 on Windows 8. I want to use openCV 3.0 with my Visual Studios. All links inside the code will be used normal and IntelliSense recognize the datamembers. But if I want to compile the programm Visual Studios give me following errors:

Fehler 1 error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""private: char * __thiscall cv::String::allocate(unsigned int)" (?allocate@String@cv@@AAEPADI@Z)" in Funktion ""public: __thiscall cv::String::String(char const *)" (??0String@cv@@QAE@PBD@Z)". C:\Users\Marc\Documents\Workspaces\C++_VS\OpenCV_Test\OpenCV_Test\main.obj OpenCV_Test Fehler 2 error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""private: void __thiscall cv::String::deallocate(void)" (?deallocate@String@cv@@AAEXXZ)" in Funktion ""public: __thiscall cv::String::~String(void)" (??1String@cv@@QAE@XZ)". C:\Users\Marc\Documents\Workspaces\C++_VS\OpenCV_Test\OpenCV_Test\main.obj OpenCV_Test Fehler 3 error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: __thiscall cv::CommandLineParser::CommandLineParser(int,char const * const * const,class cv::String const &)" (??0CommandLineParser@cv@@QAE@HQBQBDABVString@1@@Z)" in Funktion "_main". C:\Users\Marc\Documents\Workspaces\C++_VS\OpenCV_Test\OpenCV_Test\main.obj OpenCV_Test Fehler 4 error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: __thiscall cv::CommandLineParser::~CommandLineParser(void)" (??1CommandLineParser@cv@@QAE@XZ)" in Funktion "_main". C:\Users\Marc\Documents\Workspaces\C++_VS\OpenCV_Test\OpenCV_Test\main.obj OpenCV_Test Fehler 5 error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""protected: void __thiscall cv::CommandLineParser::getByName(class cv::String const &,bool,int,void *)const " (?getByName@CommandLineParser@cv@@IBEXABVString@2@_NHPAX@Z)" in Funktion ""public: class cv::String __thiscall cv::CommandLineParser::get(class cv::String const &,bool)const " (??$get@VString@cv@@@CommandLineParser@cv@@QBE?AVString@1@ABV21@_N@Z)". C:\Users\Marc\Documents\Workspaces\C++_VS\OpenCV_Test\OpenCV_Test\main.obj OpenCV_Test Fehler 6 error LNK1120: 5 nicht aufgelöste Externe C:\Users\Marc\Documents\Workspaces\C++_VS\OpenCV_Test\Debug\OpenCV_Test.exe 1 1 OpenCV_Test

I installed openCV with the following guide: http://www.minlabz.com/how-to-install-opencv-3-0-0-on-windows-7-and-configure-with-visual-studio-2014/

Here is the little code that I used to test if the openCV dependencies work:

#include "opencv2\highgui\highgui.hpp"
#include "opencv2\core\core.hpp"
#include <stdio.h>

using namespace cv;

int main(int argc, const char** argv)
{
    const char* keyMap;
    //Standard image that will be used if dont exist arguments
    keyMap = "{path     |   |  }";

    //Reading the Callingarguments
    CommandLineParser parser(argc, argv, keyMap);
    String filename = parser.get<String>("path");
}

I hope I don't forgot something simple.

4
Are there more than 2 libs in C:\opencv\build\x64\vc12\lib?drescherjm
I could use the staticlib folder in openCV and add all the libraries to the Additional Dependencies from there. I don't tested it yet. But what is the difference between the normal lib and the staticlib folder from opencv?Steno
I think in this case the linking problem would be essentially the same for static opencv or dll. Since with dll you still need to link to import libraries.drescherjm
There a only 4 libs: opecv_ts300.lib, opecv_ts300d.lib, opecv_world300.lib and opecv_ts300d.lib.Steno
I am wrong then.. This is a change from opencv 2.X.X. I deleted my first comment as a result.drescherjm

4 Answers

0
votes

When you installed the OpenCV 3 with visual studio 2013 and cmake , you will find the dlls in

\opencv\msvc\bin\Release for the release mode and the include in \opencv\build\include, therefore invoke the command prompt and type

cl /EHsc main.cpp /Fetest.exe /I D:\CPP_Libraries\opencv_3.0.0\build\include /link /LIBPATH:D:\CPP_Libraries\opencv_3.0.0\msvc\lib\Release opencv_core300.lib

with this sample

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



int main( int argc, char** argv )
{

    std::cout << "\n%%( Random Generator )%%\n"; 
    cv::Mat G = cv::Mat::ones(4,4, CV_64FC1);
    cv::Mat m = cv::Mat::zeros(1,1, CV_64FC1);
    cv::Mat s = cv::Mat::ones(1,1, CV_64FC1);
    std::cout << G << std::endl;
    cv::randn(G, m, s);
    std::cout << G << std::endl;

    return 0;
}

The result is

enter image description here

0
votes

The porblem is solved now.

I re-extract opencv and followed the steps of the following two links:

Install OpenCV 3.0 on Windows 8

Create an Visual Studio (2013) Project with openCV

0
votes

Having experienced very similar compilation error messages than those shown in the original post, I followed the thorough links above (Install OpenCV 3.0 on Windows 8, Create an Visual Studio (2013) Project with openCV).

This did not solve the compilation errors though.

What worked for me was to change the OPENCV_DIR environment variable to point to the x86 build of openCV instead of the x64 build.

-1
votes

If you had compiled opencv in x64 environment, I strongly recommend you to change x64 platform in Configuration Manager(Visual studio). I fixed same problem like this.enter image description here