-1

我正在尝试获得一个opencv c++程序,该程序在我的笔记本电脑上运行在我的硬件上——此外,我应该提到,我是嵌入式编程的新手。可能有人可以帮助我,因为我在使用VisualGDB进行交叉编译时遇到了问题。我正在使用以下板:Cubieboard 3(Cubietruck - Dual-Core A20)

工具链存储在本地 - 所以不在电路板上。所有库都包含在 Visual Studio 中并检测到 -> 看一下屏幕截图:

opencv_world320d.lib ” - 库包括所有需要的子库 - 我发现这里

C++ 代码本身:

#include "opencv2/highgui/highgui.hpp"
#include <iostream>

using namespace cv;
using namespace std;

int main(int argc, const char** argv)
{
    Mat img(500, 1000, CV_8UC3, Scalar(0, 0, 100)); //create an image ( 3 channels, 8 bit image depth, 500 high, 1000 wide, (0, 0, 100) assigned for Blue, Green and Red plane respectively. )

    if (img.empty()) //check whether the image is loaded or not
    {
        cout << "Error : Image cannot be loaded..!!" << endl;
        //system("pause"); //wait for a key press
        return -1;
    }

    namedWindow("MyWindow", CV_WINDOW_AUTOSIZE); //create a window with the name "MyWindow"
    imshow("MyWindow", img); //display the image which is stored in the 'img' in the "MyWindow" window

    waitKey(0);  //wait infinite time for a keypress

    destroyWindow("MyWindow"); //destroy the window with the name, "MyWindow"

    return 0;
}

当我尝试构建链接器失败并显示以下消息:

1>------ Erstellen gestartet: Projekt: LinuxProject2, Konfiguration: Debug VisualGDB ------
1>  Linking VisualGDB/Debug/LinuxProject2...
1>  VisualGDB/Debug/LinuxProject2.o: In function `cv::String::String(char const*)':
1>C:\OpenCV-3.2.0\opencv\build\include\opencv2\core\cvstd.hpp(622): error : undefined reference to `cv::String::allocate(unsigned int)'
1>  VisualGDB/Debug/LinuxProject2.o: In function `cv::String::~String()':
1>C:\OpenCV-3.2.0\opencv\build\include\opencv2\core\cvstd.hpp(664): error : undefined reference to `cv::String::deallocate()'
1>  VisualGDB/Debug/LinuxProject2.o: In function `cv::Mat::Mat(int, int, int, cv::Scalar_<double> const&)':
1>C:\OpenCV-3.2.0\opencv\build\include\opencv2\core\mat.inl.hpp(352): error : undefined reference to `cv::Mat::operator=(cv::Scalar_<double> const&)'
1>  VisualGDB/Debug/LinuxProject2.o: In function `cv::Mat::~Mat()':
1>C:\OpenCV-3.2.0\opencv\build\include\opencv2\core\mat.inl.hpp(592): error : undefined reference to `cv::fastFree(void*)'
1>  VisualGDB/Debug/LinuxProject2.o: In function `cv::Mat::create(int, int, int)':
1>C:\OpenCV-3.2.0\opencv\build\include\opencv2\core\mat.inl.hpp(684): error : undefined reference to `cv::Mat::create(int, int const*, int)'
1>  VisualGDB/Debug/LinuxProject2.o: In function `cv::Mat::release()':
1>C:\OpenCV-3.2.0\opencv\build\include\opencv2\core\mat.inl.hpp(704): error : undefined reference to `cv::Mat::deallocate()'
1>  VisualGDB/Debug/LinuxProject2.o: In function `main':
1>D:\Softwareentwicklung\Projects\LinuxProject2\LinuxProject2.cpp(18): error : undefined reference to `cv::namedWindow(cv::String const&, int)'
1>D:\Softwareentwicklung\Projects\LinuxProject2\LinuxProject2.cpp(19): error : undefined reference to `cv::imshow(cv::String const&, cv::_InputArray const&)'
1>D:\Softwareentwicklung\Projects\LinuxProject2\LinuxProject2.cpp(21): error : undefined reference to `cv::waitKey(int)'
1>D:\Softwareentwicklung\Projects\LinuxProject2\LinuxProject2.cpp(23): error : undefined reference to `cv::destroyWindow(cv::String const&)'
1>collect2.exe : error : ld returned 1 exit status

也许有人有同样的问题 - 我真的搜索了很多,但我找不到类似的问题。

4

1 回答 1

0

您只告诉工具链搜索库时要查找的位置(“库目录”)。您还没有告诉它要链接到哪些库......所以它无法从那些丢失的库中找到任何符号完全不足为奇。

因此,除了库搜索目录之外,您还需要使用您要引用其符号的任何库的名称填充“库名称”字段 - 在这种情况下,至少opencv. 这样,链接器可以链接到这些库,从而解析这些符号。

根据现在完全不同的问题进行编辑

基于此线程: 告诉 gcc 直接静态链接库 看起来您应该将任何静态库移动到“附加链接器”标志中,因为“库名称”会生成用于动态库的-l开关(不是-l:),但是您正在尝试链接静态库。

于 2017-08-02T19:34:20.563 回答