Unresolved Externals [closed]

asked 2015-01-30 16:01:01 -0500

updated 2015-01-31 02:17:36 -0500

Hi,

I am new to the group and OpenCV. I am coding the tutorial found in http://docs.opencv.org/doc/tutorials/... I am setting the Configuration: to Debug and Platform: to x64. Here is what the code in Visual C++ looks like:

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/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.data ) // 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 also made sure that the following library directories were added to the linker: C:\OpenCV\opencv\build\x64\vc12\staticlib C:\OpenCV\opencv\build\x64\vc12\lib

and the following libraries were added to Additional Dependencies for the Debug platform: opencv_core249d.lib opencv_imgproc249d.lib opencv_highgui249d.lib opencv_ml249d.lib opencv_video249d.lib opencv_features2d249d.lib opencv_calib3d249d.lib opencv_objdetect249d.lib opencv_contrib249d.lib opencv_legacy249d.lib opencv_flann249d.lib

and the following libraries were added to Additional Dependencies for the Release platform: opencv_core249.lib opencv_imgproc249.lib opencv_highgui249.lib opencv_ml249.lib opencv_video249.lib opencv_features2d249.lib opencv_calib3d249.lib opencv_objdetect249.lib opencv_contrib249.lib opencv_legacy249.lib opencv_flann249.lib

When I tried to build this C++ file using the x64 platform, I got 116 unresolved externals (error LNK2019). Is there something I am missing?

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by StevenPuttemans
close date 2015-02-02 09:15:33.074029

Comments

3

[for code, just mark the code and press the 101001-Button for better formatting]

FooBar gravatar imageFooBar ( 2015-01-31 02:18:07 -0500 )edit
2

this won't solve it , but you want to link either the staticlibs or the dynamic ones, not both. (library directories)

berak gravatar imageberak ( 2015-01-31 02:21:20 -0500 )edit

A guess, did you add the correct directories to your PATH variable?

StevenPuttemans gravatar imageStevenPuttemans ( 2015-01-31 02:48:09 -0500 )edit

Thanks, everyone. I liked to the wrong library directory - I should have linked to C:\OpenCV\opencv\build\x64\vc11\lib, not C:\OpenCV\opencv\build\x64\vc12\lib. And yes, berak, I should have linked only to the dynamic libraries. Once I only linked to C:\OpenCV\opencv\build\x64\vc11\lib, the project linked without any errors.

C++nerd gravatar imageC++nerd ( 2015-02-02 09:12:07 -0500 )edit