2
我试图让OpenCV的启动和运行,但我遇到了同样的问题this guy和this guy - 试图建立与该项目时,我得到链接错误C++接口,但使用C接口项目构建。
在第二个链接中,答案是“您正在混合STL.VC10(用于OpenCV)和STLPort(用于您的代码)的不同实现。”
如何确保我只使用VC10? (或更高版本)
空调风格(项目成功生成)
我使用Visual Studio 2012和OpenCV 3.0
int main(int argc, char** argv)
{
char* filename = "input.tif";
IplImage *img0;
if((img0 = cvLoadImage(filename,-1)) == 0)
return 0;
cvNamedWindow("image", 0);
cvShowImage("image", img0);
cvWaitKey(0);
cvDestroyWindow("image");
cvReleaseImage(&img0);
}
C++风格(项目不建)
int main(int argc, char** argv) {
Mat image;
const string &filename = "input.tif";
image = imread(filename, IMREAD_COLOR); // Read the file
if(! image.data) // Check for invalid input
{
std::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.
}
错误:
1>Source.obj : error LNK2019: unresolved external symbol "private: char * __thiscall cv::String::allocate(unsigned int)" ([email protected]@[email protected]@[email protected]) referenced in function "public: __thiscall cv::String::String(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" ([email protected]@@[email protected][email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@@Z)
1>Source.obj : error LNK2019: unresolved external symbol "private: void __thiscall cv::String::deallocate(void)" ([email protected]@[email protected]@AAEXXZ) referenced in function "public: __thiscall cv::String::~String(void)" ([email protected]@@[email protected])
1>Source.obj : error LNK2019: unresolved external symbol "class cv::Mat __cdecl cv::imread(class cv::String const &,int)" ([email protected]@@[email protected]@[email protected]@[email protected]) referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol "void __cdecl cv::namedWindow(class cv::String const &,int)" ([email protected]@@[email protected]@[email protected]) referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol "void __cdecl cv::imshow(class cv::String const &,class cv::_InputArray const &)" ([email protected]@@[email protected]@[email protected]@@Z) referenced in function _main
包含和在VS库路径设置
- C/C++ /普通/附加包含目录: C:\的OpenCV \建立\包括
- 链接器/普通/其他库目录: \ n C:\ opencv \ build \ x86 \ vc11 \ lib
- 链接器/输入/附加依赖: opencv_calib3d2410d.lib opencv_contrib2410d.lib opencv_core2410d.lib opencv_features2d2410d.lib opencv_flann2410d.lib opencv_gpu2410d.lib opencv_highgui2410d.lib opencv_imgproc2410d.lib opencv_legacy2410d.lib opencv_ml2410d.lib opencv_nonfree2410d.lib opencv_objdetect2410d.lib opencv_ocl2410d.lib opencv_photo2410d.lib opencv_stitching2410d.lib opencv_superres2410d.lib opencv_ts2410d.lib opencv_video2410d.lib opencv_videostab2410d.lib
你可以显示你的'#include'吗?和你的图书馆路径? – Miki
我添加了我对解决方案属性所做的更改 – Attaque
@Attaque我非常确定您不是指[tag:stl],而是移除了标记。请在下次添加标签之前阅读标签wiki。你也应该改变你的问题中的文字,而不是引用C++标准库。 –