[英]Manual for cross-compiling a C++ application from Linux to Windows?
[英]Trouble with cross-compiling an c++ openCV application for the beaglebone black
我希望有人能有一个快速的解决方案,因为我感到有点沮丧。 我正在尝试在Linux Ubuntu 14.04计算机上为Beaglebone Black(BBB)交叉编译openCV应用程序。 我安装了交叉编译器:arm-linux-gnueabihf-gcc-4.8和arm-linux-gnueabihf-g ++-4.8。 交叉。 当我编译一个简单的c ++程序而不链接到第3方库(如openCV)时,这些方法就会起作用。
因为我要为BBB进行编译,所以将beaglebone挂载(桑巴)在Linux计算机上的/ mnt / BBB /文件夹中。 我尝试了以下代码(这是http://docs.opencv.org/doc/tutorials/introduction/linux_gcc_cmake/linux_gcc_cmake.html的副本)
#include <stdio.h>
#include <opencv2/opencv.hpp>
using namespace cv;
int main(int argc, char** argv )
{
if ( argc != 2 )
{
printf("usage: DisplayImage.out <Image_Path>\n");
return -1;
}
Mat image;
image = imread( argv[1], 1 );
if ( !image.data )
{
printf("No image data \n");
return -1;
}
namedWindow("Display Image", 1 );
imshow("Display Image", image);
waitKey(0);
return 0;
}
使用以下命令:
arm-g++ -I/mnt/BBB/usr/local/include -I/mnt/BBB/usr/local/include/opencv -L/mnt/BBB/usr/local/lib -lopencv_calib3d -lopencv_core -lopencv_features2d -lopencv_flann -lopencv_highgui -lopencv_imgcodecs -lopencv_imgproc -lopencv_ml -lopencv_objdetect -lopencv_photo -lopencv_shape -lopencv_stitching -lopencv_superres -lopencv_ts -lopencv_video -lopencv_videoio -lopencv_videostab main.cpp -o main
但是我收到以下错误:
/tmp/ccX4FOL8.o: In function `main':
main.cpp:(.text+0x4c): undefined reference to `cv::imread(cv::String const&, int)'
main.cpp:(.text+0xa6): undefined reference to `cv::namedWindow(cv::String const&, int)'
main.cpp:(.text+0xe2): undefined reference to `cv::imshow(cv::String const&, cv::_InputArray const&)'
main.cpp:(.text+0xfc): undefined reference to `cv::waitKey(int)'
/tmp/ccX4FOL8.o: In function `cv::String::String(char const*)':
main.cpp:(.text._ZN2cv6StringC2EPKc[_ZN2cv6StringC5EPKc]+0x2a): undefined reference to `cv::String::allocate(unsigned int)'
/tmp/ccX4FOL8.o: In function `cv::String::~String()':
main.cpp:(.text._ZN2cv6StringD2Ev[_ZN2cv6StringD5Ev]+0xa): undefined reference to `cv::String::deallocate()'
/tmp/ccX4FOL8.o: In function `cv::_InputArray::_InputArray(cv::Mat const&)':
main.cpp:(.text._ZN2cv11_InputArrayC2ERKNS_3MatE[_ZN2cv11_InputArrayC5ERKNS_3MatE]+0x34): undefined reference to `vtable for cv::_InputArray'
/tmp/ccX4FOL8.o: In function `cv::_InputArray::~_InputArray()':
main.cpp:(.text._ZN2cv11_InputArrayD2Ev[_ZN2cv11_InputArrayD5Ev]+0x24): undefined reference to `vtable for cv::_InputArray'
/tmp/ccX4FOL8.o: In function `cv::Mat::~Mat()':
main.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x20): undefined reference to `cv::fastFree(void*)'
/tmp/ccX4FOL8.o: In function `cv::Mat::operator=(cv::Mat const&)':
main.cpp:(.text._ZN2cv3MataSERKS0_[_ZN2cv3MataSERKS0_]+0xb4): undefined reference to `cv::Mat::copySize(cv::Mat const&)'
/tmp/ccX4FOL8.o: In function `cv::Mat::release()':
main.cpp:(.text._ZN2cv3Mat7releaseEv[_ZN2cv3Mat7releaseEv]+0x3e): undefined reference to `cv::Mat::deallocate()'
collect2: error: ld returned 1 exit status
有人可以告诉我我在做什么错吗? 还是可以做得更好?
谢谢
看来您未正确链接库! 为什么不使用CMake?
target_link_libraries(your_project ${OpenCV_LIBS})
在这里,您可以找到有关交叉编译的完整参考: http : //www.vtk.org/Wiki/CMake_Cross_Compiling
无论如何,我已经在OpenCV论坛组中找到了它:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.