gpt4 book ai didi

visual-studio - OpenCV Build on Visual Studio LINK 错误

转载 作者:太空宇宙 更新时间:2023-11-03 20:41:55 30 4
gpt4 key购买 nike

我已经关注了这个 tutorial此处如前所述

我现在尝试在 Visual Studio 上运行简单的 OpenCV 代码,但我一直收到链接器错误。我正在尝试这个 OpenCV tutorial in particular

这是我不断收到的错误:

   1>Linking...
1>LINK : warning LNK4067: ambiguous entry point; selected 'mainCRTStartup'
1>OpenCV_Proj.obj : error LNK2019: unresolved external symbol "int __cdecl cv::waitKey(int)" (?waitKey@cv@@YAHH@Z) referenced in function _main
1>OpenCV_Proj.obj : error LNK2019: unresolved external symbol "void __cdecl cv::imshow(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class cv::_InputArray const &)" (?imshow@cv@@YAXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV_InputArray@1@@Z) referenced in function _main
1>OpenCV_Proj.obj : error LNK2019: unresolved external symbol "public: __thiscall cv::_InputArray::_InputArray(class cv::Mat const &)" (??0_InputArray@cv@@QAE@ABVMat@1@@Z) referenced in function _main
1>OpenCV_Proj.obj : error LNK2019: unresolved external symbol "void __cdecl cv::namedWindow(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,int)" (?namedWindow@cv@@YAXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z) referenced in function _main
1>OpenCV_Proj.obj : error LNK2019: unresolved external symbol "class cv::Mat __cdecl cv::imread(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,int)" (?imread@cv@@YA?AVMat@1@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z) referenced in function _main
1>OpenCV_Proj.obj : error LNK2019: unresolved external symbol "void __cdecl cv::fastFree(void *)" (?fastFree@cv@@YAXPAX@Z) referenced in function "public: __thiscall cv::Mat::~Mat(void)" (??1Mat@cv@@QAE@XZ)
1>OpenCV_Proj.obj : error LNK2019: unresolved external symbol "public: void __thiscall cv::Mat::copySize(class cv::Mat const &)" (?copySize@Mat@cv@@QAEXABV12@@Z) referenced in function "public: class cv::Mat & __thiscall cv::Mat::operator=(class cv::Mat const &)" (??4Mat@cv@@QAEAAV01@ABV01@@Z)
1>OpenCV_Proj.obj : error LNK2019: unresolved external symbol "public: void __thiscall cv::Mat::deallocate(void)" (?deallocate@Mat@cv@@QAEXXZ) referenced in function "public: void __thiscall cv::Mat::release(void)" (?release@Mat@cv@@QAEXXZ)
1>C:\Users\Saher\Documents\Visual Studio 2008\Projects\OpenCV_Proj\Debug\OpenCV_Proj.exe : fatal error LNK1120: 8 unresolved externals``

对于以下代码:

// OpenCV_Proj.cpp : Defines the entry point for the console application.

//

#include "stdafx.h"
#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", CV_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;
}

int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}

一段时间以来,我一直在尝试让 OpenCV 为 VS2008 工作,我们将不胜感激有关此问题的任何帮助。

注意:在本教程的自述文件中,我遵循以下内容:

1) Add build\bin and one of build\{x86|x64}\{vc9\vc10\mingw}\bin to your system path (to use DLLs)
Add build\{x86|x64}\{vc9\vc10\mingw}\lib or
build\{x86|x64}\{vc9\vc10\mingw}\staticlib as library directories to your linker settings,
Add build\include and build\include\opencv as include directories to your compiler settings.



Any help with getting this to work is really appreciated.

最佳答案

这些符号在 OpenCV 库中定义,因此您需要配置项目并让链接器知道您正在使用哪些 OpenCV 库。

至少您应该添加:opencv_core230.libopencv_highgui230.lib(对于 OpenCV 2.3.0)

有关如何在 VS2010 上执行此操作的更多信息,check this tutorial .

关于visual-studio - OpenCV Build on Visual Studio LINK 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9867514/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com