c++ - 交叉编译 VisualGDB/C++ Cubietruck => Linkererror

标签 c++ linux opencv cross-compiling visualgdb

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

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

opencv_world320d.lib” - 库包含所有需要的子库 - 我发现 here

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

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

最佳答案

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

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

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

基于此线程: Telling gcc directly to link a library statically 看来您应该将任何静态库移至“附加链接器”标志中,因为“库名称”会生成用于动态库的 -l 开关(而不是 -l:),但您正在尝试链接静态库。

关于c++ - 交叉编译 VisualGDB/C++ Cubietruck => Linkererror,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45466607/

相关文章:

c++ - std::vector 何时重新分配其内存数组?

c++ - 将 Rect 转换为 vector<Point>

大小几乎等于图像的大内核的 OPENCV 卷积

python - 在 db 中存储为字符串后检索相等的 numpy 数组

c++ - 递归可变参数模板函数调用 "loses"指针在第二个参数类型上

c++ - 如何查看 GDB 中自动变量的内存地址?

c++ - 调用析构函数时出错

android - 在C++程序中使用ADB Shell

linux - 获取带问号的行和之前的行 - sed

android - BusyBox 帮助,ip 命令