由于强迫症,实在受不了root权限的旧gcc才能使用boost而普通权限却是最新版gcc,经过一番折腾后,终于把配置全部弄好了,实际上就只需要把新版gcc的各个文件放到系统找到旧gcc的地方,并建立新版的gcc、g++的软链接就可以覆盖系统旧版的了,然后再重新编译boost即可。

  弄好之后,我又开始折腾安装OpenCV了,可能由于最新版的gcc做了一些新改动,比如cstdlib头文件中使用了#include_next <stdlib.h>这样的方式包含了头文件stdlib.h,但OpenCV的库文件可不认识,make一会而就报错:

/usr/include/c++/8.1.0/cstdlib:75:25:致命错误: stdlib.h: No such file or directory
#include_next <stdlib.h>

  参考网上,将对应错误的文件中的#include_next修改#include就可以了。

  。。。

  但进行到92%的时候又出错了,是一个python文件的assert错:

[ 92%] Generate files for Java bindings
Traceback (most recent call last):
File "/home/darkchii/下载/opencv-3.4.1/modules/java/generator/../generator/gen_java.py", line 1093, in <module>
copy_java_files(java_files_dir, target_path)
File "/home/darkchii/下载/opencv-3.4.1/modules/java/generator/../generator/gen_java.py", line 1032, in copy_java_files
src = checkFileRemap(java_file)
File "/home/darkchii/下载/opencv-3.4.1/modules/java/generator/../generator/gen_java.py", line 25, in checkFileRemap
assert path[-3:] != '.in', path
AssertionError: /home/darkchii/下载/opencv-3.4.1/modules/java/generator/src/java/org/opencv/osgi/OpenCVNativeLoader.java.in
make[2]: *** [CMakeFiles/dephelper/gen_opencv_java_source] 错误 1
make[1]: *** [modules/java_bindings_generator/CMakeFiles/gen_opencv_java_source.dir/all] 错误 2
make: *** [all] 错误 2

  网上搜了一会儿也没发现相关的问题,都是关于java异常的错误。

  由于找不到解决办法,于是打算自己动手修改源文件的一些代码,发现可行,下面就是我的解决办法:

  将gen_java.py源文件中的25行:

assert path[-3:] != '.in', path

  修改为:

assert path[-4:] != '.in', path

  即可,然后重新make,又是这个文件的错误,这次是编码错误:

[ 92%] Generate files for Java bindings
JAVA: Processing OpenCV modules: 12
duplicated: CLASS cv::.Algorithm :
SKIP:void read(FileNode fn) due to ARG typeFileNode/I
SKIP:void write(Ptr_FileStorage fs, String name = String()) due to ARG typePtr_FileStorage/I
Traceback (most recent call last):
File "/home/darkchii/下载/opencv-3.4.1/modules/java/generator/../generator/gen_java.py", line 1164, in <module>
generator.gen(srcfiles, module, dstdir, jni_path, java_path, common_headers)
File "/home/darkchii/下载/opencv-3.4.1/modules/java/generator/../generator/gen_java.py", line 492, in gen
self.save(cpp_file, T_CPP_MODULE.substitute(m = module, M = module.upper(), code = moduleCppCode.getvalue(), includes = "\n".join(includes)))
File "/home/darkchii/下载/opencv-3.4.1/modules/java/generator/../generator/gen_java.py", line 441, in save
f.write(buf)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 215-216: ordinal not in range(128)
make[2]: *** [CMakeFiles/dephelper/gen_opencv_java_source] 错误 1
make[1]: *** [modules/java_bindings_generator/CMakeFiles/gen_opencv_java_source.dir/all] 错误 2
make: *** [all] 错误 2

  于是将源文件中441行:

f.write(buf)

  修改为:

f.write(buf.encode('utf-8'))

  即可,然后重新make,于是我的问题就全解决了~

  ps:安装好以后,在gcc编译使用OpenCV的实例代码的时,如果出现'xxx'未定义的引用的ld错误,则需要在编译语句后加上链接库,例如:

g ++ -o test test.cpp `pkg-config opencv --cflags --libs`

  

CentOS7 安装 OpenCV 的一些问题解决办法的更多相关文章

  1. Centos7 安装 opencv

      Centos7 安装 opencv CentOS Linux release 7.2.1511 (Core)   1.安装依赖     yum install https://dl.fedorap ...

  2. centos7安装docker-compose报错解决办法

      docker-compose是 docker 容器的一种单机编排服务,docker-compose 是一个管理多个容器的工具,比如可以解决容器之间的依赖关系,当在宿主机启动较多的容器时候,如果都是 ...

  3. [Centos] mod_wsgi 安装流程以及遇到问题解决办法。apxs: command not found 或 Sorry, Python developer package does not appear to be installed.

    前提: Centos 系统, apache 已安装, python 已安装. 1. 首先下载mod_wsgi-3.5.tar.gz 下载地址:https://code.google.com/p/mod ...

  4. CentOS7安装MySQL冲突和问题解决小结

    摘自:https://blog.csdn.net/typa01_kk/article/details/49059729 问题1: [root@localhost install-files]# rpm ...

  5. centos7安装mariadb10遇到的问题解决

    4. 安装中的错误 4.1 /bin/ld: cannot find -lz /bin/ld: cannot find -lzcollect2: error: ld returned 1 exit s ...

  6. Eclipse安装以及安装时遇到的问题解决办法

    1, 首先要安装JDK(最好使用最新版本),注意区分32位于64位 2, 安装程序,双击打开安装即可 3, 安装包下载:http://developer.android.com/sdk/index.h ...

  7. Windows下pip安装及更新出现“UnicodeEncodeError: 'ascii' codec can't encode character u'\u258c' in position 8: ordinal not in range(128)”问题解决办法

    Windows下pip安装及更新出现“UnicodeEncodeError: 'ascii' codec can't encode character u'\u258c' in position 8: ...

  8. win10 +python3.6环境下安装opencv以及pycharm导入cv2有问题的解决办法

    一.安装opencv 借鉴的这篇博客已经写得很清楚了--------https://blog.csdn.net/u011321546/article/details/79499598       ,这 ...

  9. VMware 安装提示缺少MicrosoftRuntime DLL 问题解决办法

    VMware 安装提示缺少MicrosoftRuntime DLL 问题解决办法 刚刚安装VMware失败了试了好多办法,在这总结一下. 下面是程序的截图 这是报错信息 网上的解决方法: 当出现安装失 ...

随机推荐

  1. 【StarUML】组件图

    架构设计中可视化地表达各个组件之间依赖关系以及组件的接口调用情况 1.元素 a.组件 b.接口 b1.组件暴露接口 暴露接口,需要先画一个接口 然后建立组件和接口的联系,这里是暴露接口,那么这个连线就 ...

  2. ASA升级

    1.开启TFTP server,并且保证设备和TFTP server可达.2.上传镜像文件到ASA:ciscoasa# copy tftp: disk0: >>>>拷贝镜像到A ...

  3. Go性能调优

    文章引用自   Go性能调优 在计算机性能调试领域里,profiling 是指对应用程序的画像,画像就是应用程序使用 CPU 和内存的情况. Go语言是一个对性能特别看重的语言,因此语言中自带了 pr ...

  4. Eclipse导入git上的maven web项目 以及部署成功运行

      在公司开发的时候都是用maven 以及git环境 开发的环境,那么我们初学者怎么将公司的项目成功导入到eclipse中,并且成功运行那???下面的教程就可以告诉大家~ (ps:第二步可能是大家会遇 ...

  5. 前端开发:mock.js的简单应用(生成随机数据,拦截 Ajax 请求)

    摘要 在前端开发过程中,后端接口还没有完全开发完成时,前端开发人员就需要学会自己模拟后端接口数据,更快更好的完成开发任务.模拟后端接口数据的js库有很多,今天就简单就简单的分享下mock.js在前端开 ...

  6. uniGUI之FDQuery(28)

    1]基本设置FDQuery1.Connection2]执行查询SQL语句3]执行 非查询SQL语句4]返回所有数据 和所有 列名 1]基本设置FDQuery1.Connection 一定要 放一个   ...

  7. 面试问烂的 Spring AO,全文详解

    本人免费整理了Java高级资料,涵盖了Java.Redis.MongoDB.MySQL.Zookeeper.Spring Cloud.Dubbo高并发分布式等教程,一共30G,需要自己领取.传送门:h ...

  8. 读书笔记, Python - python-tricks-buffet-awesome-features

    To be a Pythonista 1. assert syntax: assert expression1 [",", expression2] 大致相当于 if __debu ...

  9. phpinfo(): It is not safe to rely on the system's timezone settings

    PHP调试的时候出现了警告: 问题: Warning: phpinfo(): It is not safe to rely on the system's timezone settings. You ...

  10. css与js基础

    CSS样式 1 宽高设置 块元素可使用 wid 1字体 font-family :  文本类型 font-size     字体大小 font-style 字体样式 斜体italic   正常norm ...