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

时间:2017-08-02 16:46:31

标签: 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

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

1 个答案:

答案 0 :(得分:0)

在搜索库时,您只告诉工具链 (“库目录”)。你还没有告诉它哪些库链接到......所以它无法从那些缺少的库中找到任何符号就完全不足为奇了。

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

按照现在完全不同的问题进行编辑

基于这个帖子: Telling gcc directly to link a library statically 您似乎应该将任何静态库移动到“其他链接器”标志中,因为“库名称”生成-l开关(不是-l:),这些开关用于动态库,但您正在尝试链接静态库。