Ask Your Question
0

Imshow error in visual studio 2017

asked 2018-04-06 04:43:35 -0600

updated 2018-04-06 04:50:25 -0600

berak gravatar image

code:

#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], CV_LOAD_IMAGE_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;
}

When i run this code.I give 2 error :

Severity    Code    Description Project File    Line    Suppression State
Error   LNK2001 unresolved external symbol "void __cdecl cv::imshow(class cv::String const &,class cv::_InputArray const &)" (?imshow@cv@@YAXAEBVString@1@AEBV_InputArray@1@@Z)

Can you help me? Thanks!

edit retag flag offensive close merge delete

Comments

which opencv version are you using?

vps gravatar imagevps ( 2018-04-06 06:27:48 -0600 )edit
1

You run nothing : it's a link error. how do you build VS solution? you need openc_worl.lib or opencv_highgui.lib....

LBerger gravatar imageLBerger ( 2018-04-06 06:28:40 -0600 )edit

1 answer

Sort by » oldest newest most voted
0

answered 2018-05-17 01:03:47 -0600

gue22 gravatar image

updated 2018-05-17 06:59:56 -0600

Edit and additions in response to @LBerger 's comment:
~~I´m not such a programming authority to give answers with why some things work or don´t, but there apparently are some serious omissions in the Win-VS-tutorial, at least for VS 2017.~~ (strike-through s element seems to work, but not tildes?)

More carefully phrased with enough time on hand with the proposed solution (below) already out:
I found the Win-VS-tutorial very helpful, but though I´ve done a lot of programming for decades, I´m no expert in OpenCV and C++ and VS and all their variants and dependencies, so the below was not the only pit, even in this tiny sample and reading carefully.

(I had tried to get VisionWorks with OpenCV running on Windoze (with the Jetson in mind), but took the step back because of all the "moving parts" overwhelming me.)

Quick shot:
What helps: 2 different PropertySheet.props
One for Debug with Linker > Input > Additional Dependencies > opencv_world341d.lib (with the d for debug in it) and for Release with opencv_world341.lib

Hope that helps
G.

edit flag offensive delete link more

Comments

Yes doc it's old but it is written :

The letter d at the end just indicates that these are the libraries required for the debug. Now click ok to save and do the same with a new property inside the Release rule section. Make sure to omit the d letters from the library names and to save the property sheets with the save icon above them.
LBerger gravatar imageLBerger ( 2018-05-17 01:19:55 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2018-04-06 04:43:35 -0600

Seen: 2,417 times

Last updated: May 17 '18