海思3515,交叉编译opencv2.4.9

编译环境:

    我使用的是vmare虚拟机下的redhat9.0,交叉编译工具为海思3515官方配的编译工具gcc-3.4.3-uClibc,opencv版本为2.4.9。cmake版本为3.1.1,使用的是已经编译好的程序,包含cmake-gui。下图是安装好之后的交叉编译工具目录。


安装步骤:

①准备工作

安装好海思交叉编译工具,编译工具官方开发板有配,在SDK的toolchains目录下有安装包。安装cmake,可以下载源码进行编译安装,也可以直接下载已经编译好的程序使用,版本建议2.8,我测试使用的是3.1.1。opencv2.4.9源码,可从opencv官网下载,Linux版本。

②建立相关目录

新建一个文件夹,本例中命名为“opencv”,将opencv源码拷贝至该文件夹,并解压。在文件夹中另外新建两个文件夹:build(用于对源码进行编译),output(用于存放最后输出的库文件等)。

③配置cmake

将cmake-gui拷贝至/bin或者将cmake-gui所在目录加入PATH中。在命令行中输入:cmake-gui,打开cmake图形界面进行配置。本例中配置如下:


如下图,operation stystem和version processor随便写,编译器分别选择arm-hismall-linux-gcc和arm-hismall-linux-g++,targetroot选择arm-linux编译器的头文件目录,我这里是/opt/hisi-linux/x86-arm/gcc-3.4.3-uClibc-0.9.28/usr/include/。点击finish完成。


然后,华丽丽地报错了。


查询错误信息,提到了CUDA,百度查了下,是某显卡相关库,对于arm-linux交叉编译没有用,本机也没有安装。

取消以下选项:

with-cuda

with-opencl

build-opencv-ocl


故在列表中取消与之相关的的项,重新点击configure。没有报错了。

否则还有报错: undefined reference to `dlopen'



由于arm-linux有很多库是没有的,所以在配置这一步还要取消很多的选项。这些选项可以根据本人实际需求进行取舍,本例具体配置如下。


④make

继续点generate,生成make配置文件。然后,进入build目录,开始make。编译出错,提示:

/opt/hisi-linux/x86-arm/gcc-3.4.3-uClibc-0.9.28/bin/../../gcc-3.4.3-uClibc-0.9.28//usr/include/stdlib.h:691:error: syntax error before '*' token

/opt/hisi-linux/x86-arm/gcc-3.4.3-uClibc-0.9.28/bin/../../gcc-3.4.3-uClibc-0.9.28//usr/include/stdlib.h:695:error: syntax error before "wchar_t"

/opt/hisi-linux/x86-arm/gcc-3.4.3-uClibc-0.9.28/bin/../../gcc-3.4.3-uClibc-0.9.28//usr/include/stdlib.h:699:error: syntax error before '*' token

/opt/hisi-linux/x86-arm/gcc-3.4.3-uClibc-0.9.28/bin/../../gcc-3.4.3-uClibc-0.9.28//usr/include/stdlib.h:703:error: syntax error before '*' token

make[2]: ***

[3rdparty/zlib/CMakeFiles/zlib.dir/gzclose.c.obj] Error 1

make[1]: ***

[3rdparty/zlib/CMakeFiles/zlib.dir/all] Error 2

make: *** [all] Error 2

解决办法:打开stdlib.h文件,将684行和706行的#ifdef….   #endif注释取消。

继续make,然后出错。提示:

In file included from

/root/opencv/opencv-2.4.9/modules/core/include/opencv2/core/core.hpp:4855,

                

                  from/root/opencv/opencv-2.4.9/modules/core/src/precomp.hpp:48,

                      

                  from/root/opencv/opencv-2.4.9/modules/core/src/algorithm.cpp:43:

 

/root/opencv/opencv-2.4.9/modules/core/include/opencv2/core/operations.hpp:4024:error: got 2 template parameters for `voidcv::AlgorithmInfo::addParam(cv::Algorithm&, const char*,cv::Ptr<_Tp2>&, bool, cv::Ptr<_Tp2> (cv::Algorithm::*)(), void(cv::Algorithm::*)(const cv::Ptr<_Tp2>&), const std::string&)'

 

/root/opencv/opencv-2.4.9/modules/core/include/opencv2/core/operations.hpp:4024:error:   but 1 required

 

/root/opencv/opencv-2.4.9/modules/core/include/opencv2/core/operations.hpp:4033:error: redefinition of `void cv::AlgorithmInfo::addParam(cv::Algorithm&,const char*, cv::Ptr<_Tp2>&, bool, cv::Ptr<_Tp2>(cv::Algorithm::*)(), void (cv::Algorithm::*)(const cv::Ptr<_Tp2>&),const std::string&)'

 

/root/opencv/opencv-2.4.9/modules/core/include/opencv2/core/operations.hpp:4024:error: `void cv::AlgorithmInfo::addParam(cv::Algorithm&, const char*,cv::Ptr<_Tp2>&, bool, cv::Ptr<_Tp2> (cv::Algorithm::*)(), void(cv::Algorithm::*)(const cv::Ptr<_Tp2>&), const std::string&)'previously declared here

make[2]: ***

[modules/core/CMakeFiles/opencv_core.dir/src/algorithm.cpp.obj] Error 1

make[1]: *** [modules/core/CMakeFiles/opencv_core.dir/all] Error 2

make: *** [all] Error 2

解决办法:进入operations.hpp,将4021行的那个函数注释掉。

继续make,然后又有新错误出现了。

In file included from /root/opencv/opencv-2.4.9/modules/core/src/precomp.hpp:48,

                 from/root/opencv/opencv-2.4.9/modules/core/src/persistence.cpp:43:

/root/opencv/opencv-2.4.9/modules/core/include/opencv2/core/core.hpp:4826:warning: `class cv::TLSDataContainer' has virtual functions but non-virtualdestructor

/root/opencv/opencv-2.4.9/modules/core/src/persistence.cpp:48:19:wchar.h: No such file or directory

/root/opencv/opencv-2.4.9/modules/core/src/persistence.cpp: In function`std::string cv::fromUtf16(const cv::WString&)':

/root/opencv/opencv-2.4.9/modules/core/src/persistence.cpp:166: error:`wcstombs' undeclared (first use this function)

/root/opencv/opencv-2.4.9/modules/core/src/persistence.cpp:166: error:(Each undeclared identifier is reported only once for each function it appearsin.)

/root/opencv/opencv-2.4.9/modules/core/src/persistence.cpp: In function`cv::WString cv::toUtf16(const std::string&)':

/root/opencv/opencv-2.4.9/modules/core/src/persistence.cpp:178: error:`mbstowcs' undeclared (first use this function)

make[2]: ***[modules/core/CMakeFiles/opencv_core.dir/src/persistence.cpp.obj] Error 1

make[1]: *** [modules/core/CMakeFiles/opencv_core.dir/all] Error 2

make: *** [all] Error 2

解决办法:wchar.h文件其实在usr/include/bits目录下,故打开persistence.cpp文件,在48行处,将#include<wchar.h>改为#include<bits/wchar.h>,错误减少了,但没有解决。还是会提示wcstombs函数没有定义。该函数包含在stdlib.h里,进入该头文件,将684行和706行的#ifdef#endif注释掉,错误解决。

继续make,然后继续出错提示:

/root/opencv/opencv-2.4.9/modules/core/src/system.cpp:898: error:`pthread_spin_init' undeclared (first use this function)

/root/opencv/opencv-2.4.9/modules/core/src/system.cpp:898: error: (Eachundeclared identifier is reported only once for each function it appears in.)

/root/opencv/opencv-2.4.9/modules/core/src/system.cpp: In destructor`cv::Mutex::Impl::~Impl()':

/root/opencv/opencv-2.4.9/modules/core/src/system.cpp:899: error:`pthread_spin_destroy' undeclared (first use thisfunction)/root/opencv/opencv-2.4.9/modules/core/src/system.cpp: In memberfunction `void cv::Mutex::Impl::lock()':

/root/opencv/opencv-2.4.9/modules/core/src/system.cpp:901: error:`pthread_spin_lock' undeclared (first use this function)

/root/opencv/opencv-2.4.9/modules/core/src/system.cpp: In memberfunction `bool cv::Mutex::Impl::trylock()':

/root/opencv/opencv-2.4.9/modules/core/src/system.cpp:902: error:`pthread_spin_trylock' undeclared (first use thisfunction)/root/opencv/opencv-2.4.9/modules/core/src/system.cpp: In memberfunction `void cv::Mutex::Impl::unlock()':

/root/opencv/opencv-2.4.9/modules/core/src/system.cpp:903: error: `pthread_spin_unlock'undeclared (first use this function)

make[2]: ***[modules/core/CMakeFiles/opencv_core.dir/src/system.cpp.obj] Error 1

make[1]: *** [modules/core/CMakeFiles/opencv_core.dir/all] Error 2

make: *** [all] Error 2

解决办法:直接将893行到908行的条件编译代码注释掉,问题解决。

继续make,然后出错。提示:

/root/opencv/opencv-2.4.9/modules/core/src/system.cpp:898: error:`pthread_spin_init' undeclared (first use this function)

/root/opencv/opencv-2.4.9/modules/core/src/system.cpp:898: error: (Eachundeclared identifier is reported only once for each function it appears in.)

/root/opencv/opencv-2.4.9/modules/core/src/system.cpp: In destructor`cv::Mutex::Impl::~Impl()':

/root/opencv/opencv-2.4.9/modules/core/src/system.cpp:899: error:`pthread_spin_destroy' undeclared (first use thisfunction)/root/opencv/opencv-2.4.9/modules/core/src/system.cpp: In memberfunction `void cv::Mutex::Impl::lock()':

/root/opencv/opencv-2.4.9/modules/core/src/system.cpp:901: error:`pthread_spin_lock' undeclared (first use this function)

/root/opencv/opencv-2.4.9/modules/core/src/system.cpp: In memberfunction `bool cv::Mutex::Impl::trylock()':

/root/opencv/opencv-2.4.9/modules/core/src/system.cpp:902: error:`pthread_spin_trylock' undeclared (first use thisfunction)/root/opencv/opencv-2.4.9/modules/core/src/system.cpp: In memberfunction `void cv::Mutex::Impl::unlock()':

/root/opencv/opencv-2.4.9/modules/core/src/system.cpp:903: error:`pthread_spin_unlock' undeclared (first use this function)

make[2]: *** [modules/core/CMakeFiles/opencv_core.dir/src/system.cpp.obj]Error 1

make[1]: *** [modules/core/CMakeFiles/opencv_core.dir/all] Error 2

make: *** [all] Error 2

解决办法:test文件编译出错,进入cmake-gui,取消ts模块的勾选。该模块是用于测试的,可以不用勾选。重新configuregeneration。错误解决。

继续make,然后出错,提示:

/root/opencv/opencv-2.4.9/modules/legacy/src/pyrsegmentation.cpp:In function `CvStatus icvPyrSegmentation8uC3R(uchar*, int, uchar*, int, CvSize,int, CvSeq**, CvMemStorage*, int, int, int)':

/root/opencv/opencv-2.4.9/modules/legacy/src/pyrsegmentation.cpp:1023:internal compiler error: in verify_local_live_at_start, at flow.c:546

Please submit a full bug report,

with preprocessed source ifappropriate.

Send email to arm-gnu@codesourcery.comfor instructions.

make[2]: ***[modules/legacy/CMakeFiles/opencv_legacy.dir/src/pyrsegmentation.cpp.obj] Error1

make[1]: ***[modules/legacy/CMakeFiles/opencv_legacy.dir/all] Error 2

make: *** [all] Error 2

解决办法:进入pyrsegmentation.cpp,将CvStatus icvPyrSegmentation8uC3R函数里的代码清空,直接在函数里填上”return CV_OK;”,问题解决。

继续make,然后终于完成了。

⑤make install

输入命令make install,完成安装。此时,可以在output目录下找到相关的头文件和库文件目录了。终于完成了,看到这么多错误,我也是醉了。

另外,我记得有一次编译还遇到一个cvsample.cpp相关的错误,最后的办法是在cmake取消了apps的勾选,就是不编译opencv的例程。然后,那个错误就解决了。

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值