0

它们是我在 Windows 8 上的 Visual Studios 2013 中的 C++ 链接器的问题。我想在我的 Visual Studios 中使用 openCV 3.0。代码中的所有链接都将正常使用,并且 IntelliSense 会识别数据成员。但是如果我想编译程序 Visual Studios 给我以下错误:

Fehler 1 错误 LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""private: char * __thiscall cv::String::allocate(unsigned int)" (?allocate@String@cv@@AAEPADI@Z)" in Funktion ""public: __thiscall cv::String::String(char const *)" (??0String@cv@@QAE@PBD@Z)"。C:\Users\Marc\Documents\Workspaces\C++_VS\OpenCV_Test\OpenCV_Test\main.obj OpenCV_Test Fehler 2 错误 LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""private: void __thiscall cv::String::deallocate(void )" (?deallocate@String@cv@@AAEXXZ)" in Funktion ""public: __thiscall cv::String::~String(void)" (??1String@cv@@QAE@XZ)"。C:\Users\Marc\Documents\Workspaces\C++_VS\OpenCV_Test\OpenCV_Test\main.obj OpenCV_Test Fehler 3 错误 LNK2019: Verweis auf nicht aufgelöstes externes Symbol "

我使用以下指南安装了 openCV:http: //www.minlabz.com/how-to-install-opencv-3-0-0-on-windows-7-and-configure-with-visual-studio-2014/

这是我用来测试 openCV 依赖项是否有效的小代码:

#include "opencv2\highgui\highgui.hpp"
#include "opencv2\core\core.hpp"
#include <stdio.h>

using namespace cv;

int main(int argc, const char** argv)
{
    const char* keyMap;
    //Standard image that will be used if dont exist arguments
    keyMap = "{path     |   |  }";

    //Reading the Callingarguments
    CommandLineParser parser(argc, argv, keyMap);
    String filename = parser.get<String>("path");
}

我希望我不会忘记一些简单的事情。

4

4 回答 4

0

当您使用 Visual Studio 2013 和 cmake 安装 OpenCV 3 时,您会在

\opencv\msvc\bin\Release对于发布模式和includein \opencv\build\include,因此调用命令提示符并键入

cl /EHsc main.cpp /Fetest.exe /I D:\CPP_Libraries\opencv_3.0.0\build\include /link /LIBPATH:D:\CPP_Libraries\opencv_3.0.0\msvc\lib\Release opencv_core300.lib

有了这个样本

#include <iostream>
#include <opencv2/core/core.hpp>



int main( int argc, char** argv )
{

    std::cout << "\n%%( Random Generator )%%\n"; 
    cv::Mat G = cv::Mat::ones(4,4, CV_64FC1);
    cv::Mat m = cv::Mat::zeros(1,1, CV_64FC1);
    cv::Mat s = cv::Mat::ones(1,1, CV_64FC1);
    std::cout << G << std::endl;
    cv::randn(G, m, s);
    std::cout << G << std::endl;

    return 0;
}

结果是

在此处输入图像描述

于 2015-05-06T00:38:21.147 回答
0

问题现在解决了。

我重新提取opencv并按照以下两个链接的步骤操作:

在 Windows 8 上安装 OpenCV 3.0

使用 openCV 创建 Visual Studio (2013) 项目

于 2015-05-07T07:52:57.997 回答
0

在经历了与原始帖子中显示的非常相似的编译错误消息后,我按照上面的完整链接进行操作(在 Windows 8 上安装 OpenCV 3.0,使用 openCV 创建 Visual Studio (2013) 项目)。

但这并没有解决编译错误。

对我有用的是更改 OPENCV_DIR 环境变量以指向 openCV 的 x86 构建而不是 x64 构建。

于 2015-08-03T20:27:12.583 回答
-1

如果您在 x64 环境下编译过 opencv,我强烈建议您在 Configuration Manager(Visual Studio) 中更改 x64 平台。我解决了同样的问题。在此处输入图像描述

于 2016-07-23T01:17:13.220 回答