1
votes

I'm trying to run visual c++ with OpenCV. I have linked the OpenCV to Visual studio 2012. when I tried to run the code, it's giving me an error;

LINK : fatal error LNK1104: cannot open file 'opencv_calib2d246.dll'

Here's what I was trying to do:

#include "stdafx.h"
#include "opencv2\highgui\highgui.hpp"
#include "opencv2\core\core.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_UNCHANGED);

    if(! image.data)
    {
        cout<<"couldn't open or find the image"<<endl;
        return -1;
    }

    namedWindow("Display Window",WINDOW_AUTOSIZE);
    imshow("Display Window",image);

    waitKey(0);
    return 0;
}

I have included all the libraries. I'm using OpenCV 2.4.6, on windows 7 32 bit system.

enter image description here

Anything more I have to add, or do I have to initialize it in the program?

Update

The path for OpenCV in my hard disk :E:\opencv\opencv. Path in the system environment variable: %OPENCV_DIR%\x86\vc11\bin;, where I have created a new variable as OPENCV_DIR and have given the path as E:\opencv\opencv\build. And in linker\command line

/OUT:"E:\VS2012 Projects\cvtest\Debug\cvtest.exe" /MANIFEST /NXCOMPAT /PDB:"E:\VS2012 Projects\cvtest\Debug\cvtest.pdb" /DYNAMICBASE "opencv_calib3d248.lib" "opencv_calib3d248d.lib" "opencv_contrib248.lib" "opencv_contrib248d.lib" "opencv_core248.lib" "opencv_core248d.lib" "opencv_features2d248.lib" "opencv_features2d248d.lib" "opencv_flann248.lib" "opencv_flann248d.lib" "opencv_gpu248.lib" "opencv_gpu248d.lib" "opencv_highgui248.lib" "opencv_highgui248d.lib" "opencv_imgproc248.lib" "opencv_imgproc248d.lib" "opencv_legacy248.lib" "opencv_legacy248d.lib" "opencv_ml248.lib" "opencv_ml248d.lib" "opencv_nonfree248.lib" "opencv_nonfree248d.lib" "opencv_objdetect248.lib" "opencv_objdetect248d.lib" "opencv_ocl248.lib" "opencv_ocl248d.lib" "opencv_photo248.lib" "opencv_photo248d.lib" "opencv_stitching248.lib" "opencv_stitching248d.lib" "opencv_superres248.lib" "opencv_superres248d.lib" "opencv_ts248.lib" "opencv_ts248d.lib" "opencv_video248.lib" "opencv_video248d.lib" "opencv_videostab248.lib" "opencv_videostab248d.lib" "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" /DEBUG /MACHINE:X86 /INCREMENTAL /PGD:"E:\VS2012 Projects\cvtest\Debug\cvtest.pgd" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /ManifestFile:"Debug\cvtest.exe.intermediate.manifest" /ERRORREPORT:PROMPT /NOLOGO /TLBID:1

Now I'm not able to load image. No fatal errors and nothing. It is considering the if statement and not loading anything.

Any suggestions?

1
did you add reference to this dll? i tried using opencv in c# i just added it in the referenceDarkMakukudo
go to linker/general and add the path where that .lib file is located to "additonal linker directories" or similarMicka
@Micka I have checked the path. I have specified the path as well. Still I'm getting the same error.varsha_holla
@EuphoriaGrogi I haven't tried it by adding the reference. I will check that out.varsha_holla
either add : %OPENCV_DIR%\x86\vc11\lib; to system PATH environmental variable or add it to "additional library directories" in linker->generalMicka

1 Answers

2
votes

You need to set up more than just your linker dependencies and it is very likely you have missed a step.

I would suggest following this tutorial as it will get you setup completely.