how can i solve the link error My visual C++ 2008 with OpenCV?
I am the very bignner for the OpenCV.
I’ve just install the OpenCV and make the C++ program as follow.
My compiler is visual C++ 2008.
# include "highgui.h"
void main() {
IplImage* img = cvLoadImage("C:/OpenCV/samples/cpp/tutorial_code/images/lena.png",-1);
cvNamedWindow("lena",0);
cvShowImage("lena",image);
cvWaitKey(0);
cvReleaseImage(&image);
}
But it could not be built with the error message, and I cannot solve this problem.
The error message is as follow.
(My compiler is Korean Version and I translate the error message into English. And the English is poor, but you may understand how it was processed.)
1>------ begin build: project: image1st,: Debug Win32 ------
1> compiling)
1>image1st.cpp
1>c:\vs2008\ccp_file\image1st\image1st.cpp(17) : warning C4700: not inetialized ‘image’ use local variable
1>Microsoft (R) Windows (R) Resource Compiler Version 6.1.6723.1
1>Copyright (C) Microsoft Corporation. All rights reserved.
1>linking
1>image1st.obj : error LNK2019: _cvReleaseImage External Symbol(refrence positon: _main function) not defined.
1> image1st.obj : error LNK2019: _cvWaitKey External Symbol(refrence positon: _main function)not defined.
1> image1st.obj : error LNK2019: _cvShowImage External Symbol(refrence positon: _main function)not defined.)
1> image1st.obj : error LNK2019: _cvNamedWindow External Symbol(refrence positon: _main function)not defined.)
1>image1st.obj : error LNK2019: _cvLoadImage External Symbol(refrence positon: _main function)not defined.)
1>project: warning PRJ0018 : can not find the next environment variable.
1>$(OPENCV_DIR)
1>image1st – errors: 6, warning: 1
And I modified the visual c++ environment are modified as follow.
And I input “$(OPENCV_DIR)\include” in the “Additional Include Directories” entry,
and make the “Additional Dependencies” entry to include the next .lib file as the OpenCV Tutorials Release 2.3 guides.
- ‘opencv_core231d.lib’
- ‘opencv__imgproc231d.lib’
- ‘opencv__highgui231d.lib’
- ‘opencv__ml231d.lib’
- ‘opencv__video231d.lib’
- ‘opencv__features2d231d.lib’
- ‘opencv__calib3d231d.lib’
- ‘opencv__objdetect231d.lib’
- ‘opencv__contrib231d.lib’
- ‘opencv__legacy231d.lib’
- ‘opencv__flann231d.lib’
And the include and library directories of visual c++ environment are modified as follow.
For library:
- $(VSInstallDir)lib
- $(VSInstallDir)
- $(FrameworkSDKDir)lib
- $(WindowsSdkDir)\lib
- $(VCInstallDir)atlmfc\lib\i386
- $(VCInstallDir)atlmfc\lib
- $(VCInstallDir)lib
- C:\opencv\build\x86\vc10\lib // modified
- C:\opencv\build\x86\vc9开发者_Go百科\lib // modified
- C:\opencv\build\x64\vc10\lib // modified
- C:\opencv\build\x64\vc9\lib // modified
- C:\opencv\build\gpu\x86\lib // modified
- C:\opencv\build\gpu\x64\lib // modified
For include:
- $(VCInstallDir)atlmfc\include
- $(WindowsSdkDir)\include
- $(FrameworkSDKDir)include
- $(VCInstallDir)include
- C:\OpenCV\build\include\opencv // modified
- C:\OpenCV\build\include\opencv2 // modified
- C:\opencv\build\include // modified
It's seems that your processor can't recognize the user vairble OPEN_CV first, make sure that the system\user vairble is correct. in order to do that go to system properties --> on advance menu --> to go Enviroment variables --> make sure your system variable is correct , if not please create one with the path to your open cv library location.
it's seems like you are doing everything right , I believe your problem is that you have missed some at the post build step ...
Second , you'll have to copy the dll files from the openCV library to the location of your project. in order to do so , please include an appropriate path on the post build step on your project. go to your project : properties ... watch the picture
and include the command:
copy "C:\OpenCV2.31\CMake_Build\bin\Debug\*.dll"
copy "C:\OpenCV2.31\CMake_Build\bin\Debug\*.pdb"
Good luck
S
Basically it seems, that the compiler cannot find the OpenCV libraries or has trouble identifying the right one.
Make sure, that the needed libraries (i.e. opencv__xxx.lib
) can be found in the directories you specified in the library directories (C:\opencv\build\x86\vc10\lib
etc.) Also, you should only specify the directories for your platform, i.e. only vc9
(since you're using VS2008) and x86
/x64
depending on your architecture.
The PRJ0018
warning indicates, that the OPENCV_DIR
environment variable is not set. You can do this in the System properties dialog (usually you get it by right-clicking on "My Computer" and select "Properties", in Win7/Vista you have to go to "Extended System settings") on the "Extended" Tab, there's a Button "Environment variables". But if you already modified the include directories, you can omit the "Additional include directories" setting anyway.
may be it can help you.
Using OpenCV 2.1 with MS Visual Studio
OpenCV 2.1.0 with Visual Studio 2008
精彩评论