本文为https://github.com/amy-tabb/RWHEC-Tabb-AhmadYousef的环境搭配
写的有点乱,遇到类似问题可以直接ctrl+f进行全局搜索查找
sudo命令:
Linux sudo命令以系统管理者的身份执行指令,也就是说,经由 sudo 所执行的指令就好像是 root 亲自执行。
简单的说,sudo 是一种权限管理机制,管理员可以授权于一些普通用户去执行一些 root 执行的操作,而不需要知道 root 的密码。
apt:
有点类似pip
--------------------------------------从零开始安装步骤---------------------------------------------------------------
通过sudo apt安装了eclipse:Ubuntu安装Eclipse教程 Ubuntu安装Eclipse详细步骤 - 美国主机侦探
安装了g++、gcc :
sudo apt-get install gcc g++
安装了git:比较复杂 百度一下 还有ssd秘钥
安装了cmake和make:
sudo apt-get install make cmake
运行到官网Readme中代码块这句(这句来自下面)
cmake -G"Eclipse CDT4 - Unix Makefiles" -DCMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT=TRUE ../code_src/
一直报错 显示错误:
-- Eclipse version is set to 3.6 (Helios). Adjust CMAKE_ECLIPSE_VERSION if this is wrong.
CMake Error at CMakeLists.txt:7 (find_package):
By not providing "FindCeres.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "Ceres", but
CMake did not find one.
Could not find a package configuration file provided by "Ceres" with any of
the following names:
CeresConfig.cmake
ceres-config.cmake
Add the installation prefix of "Ceres" to CMAKE_PREFIX_PATH or set
"Ceres_DIR" to a directory containing one of the above files. If "Ceres"
provides a separate development package or SDK, be sure it has been
installed.
应该是没有ceres 根据官网
Installation — Ceres Solver
安装笔记 一步步操作
# CMake sudo apt-get install cmake # google-glog + gflags sudo apt-get install libgoogle-glog-dev libgflags-dev # BLAS & LAPACK sudo apt-get install libatlas-base-dev # Eigen3 sudo apt-get install libeigen3-dev # SuiteSparse and CXSparse (optional) sudo apt-get install libsuitesparse-dev
然后获取ceres源代码
git clone https://ceres-solver.googlesource.com/ceres-solver
安装完根据官网操作
tar zxf ceres-solver-2.0.0.tar.gz mkdir ceres-bin cd ceres-bin cmake ../ceres-solver-2.0.0 make -j3 make test # Optionally install Ceres, it can also be exported using CMake which # allows Ceres to be used without requiring installation, see the documentation # for the EXPORT_BUILD_DIR option for more information. make install
到cmake ../这一行的时候
卡在
Detected Ceres being used as a git submodule, adding commit hook for Gerrit to: /home/jqx/ceres-solv
后过了几分钟就好了。。 显示
-- Build the examples.
-- Configuring done
-- Generating done
-- Build files have been written to: /home/jqx/ceres-bin
继续操作
下面一句
▶make并发执行命令:make -j3 #同时开启3个进程去编译 makefile中的每个命令,都会开启一个新的进程去执行; 如果多条命令相关,要在一个进程中完成,则命令结尾追加:[; \] #中括号中的;
这里j3太少了,参考
$make -j8 //可用nproc这个命令查看cpu核心数,我的cpu核心数是8
改为 make -j4 因为默认给的1 我分了4处理器
编译到49%的时候报错
See <file:///usr/share/doc/gcc-7/README.Bugs> for instructions. examples/CMakeFiles/nist.dir/build.m
examples/CMakeFiles/nist.dir/build.make:62: recipe for target 'examples/CMakeFiles/nist.dir/nist.cc.
[ 49%] Built target manifold_test Makefile:140: recipe for target 'all' failed make: *** [all] Error
gcc编译报错 gcc: internal compiler error_pass_but_fail的博客-CSDN博客
根据这个应该是内存不够?把虚拟机的内存分配到4G后继续
然后nproc查看内核并且把虚拟机内核设置成4(默认1)后make速度飙升!
最后一步make install的时候报错
-- Install configuration: "Release"
CMake Error at cmake_install.cmake:41 (file):
file cannot create directory: /usr/local/lib/cmake/Ceres. Maybe need
administrative privileges.
Makefile:128: recipe for target 'install' failed
make: *** [install] Error 1
因为没有管理者权限
改为用sudo make install后错误消失
至此完成ceres的编译
---------------------------------------------------------------------------------------------------------------------------------
源码安装:git clone https://github.com/amy-tabb/RWHEC-Tabb-AhmadYousef.git
如果报错
fatal: unable to access 'https://github.com/amy-tabb/RWHEC-Tabb-AhmadYousef.git。/': gnutls_handshake() failed: Error in the pull function.
那么就把https://改成git:/
下载完成 到
cmake -G"Eclipse CDT4 - Unix Makefiles" -DCMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT=TRUE ../code_src/
的时候报错
Policy CMP0057 is not set: Support new IN_LIST if() operator. Run "cmake
--help-policy CMP0057" for policy details. Use the cmake_policy command to set the policy and suppress this warning.
IN_LIST will be interpreted as an operator when the policy is set to NEW.
Since the policy is not set the OLD behavior will be used.
Call Stack (most recent call first):
/usr/share/cmake-3.10/Modules/CMakeFindDependencyMacro.cmake:48 (find_package)
/usr/local/lib/cmake/Ceres/CeresConfig.cmake:183 (find_dependency)
CMakeLists.txt:7 (find_package)
This warning is for project developers. Use -Wno-dev to suppress it.CMake Error at /usr/local/lib/cmake/Ceres/FindSuiteSparse.cmake:115 (if):
if given arguments:"CHOLMOD" "IN_LIST" "SuiteSparse_FIND_COMPONENTS"
Unknown arguments specified
Call Stack (most recent call first):
翻译:未设置策略CMP0057:支持新的IN_LIST if()运算符。运行“cmake”
--“帮助策略CMP0057”获取策略详细信息。使用cmake_策略命令设置策略并抑制此警告。
当策略设置为NEW时,IN_LIST将被解释为运算符。
由于未设置策略,因此将使用旧行为。
调用堆栈(最新调用优先):
/usr/share/cmake-3.10/Modules/cmakefindependencyMacro。cmake:48(查找包)
/usr/local/lib/cmake/Ceres/CeresConfig。cmake:183(查找依赖项)
此警告适用于项目开发人员。使用-Wno-dev来抑制它。
CMake错误位于/usr/local/lib/CMake/Ceres/FindSuiteSparse。cmake:115(如果有):
如果给出了参数:
“CHOLMOD”“IN_LIST”“SuiteSparse_FIND_COMPONENTS”
指定了未知参数
调用堆栈(最新调用优先):
解决办法:
解决cmake Policy CMP0057 is not set: Support new IN_LIST if() operator_Woosual的博客-CSDN博客 根据错误找到这个文件 搜索 打开文本 然后加入这一块
if(POLICY CMP0057)
cmake_policy(SET CMP0057 NEW) #注意一定要TAB缩进啊。。。
endif()
没用
结果终端里输入
cmake --help-policy CMP0057
得到提示
Support new ``if()`` IN_LIST operator.CMake 3.3 adds support for the new IN_LIST operator.
The ``OLD`` behavior for this policy is to ignore the IN_LIST operator.
The ``NEW`` behavior is to interpret the IN_LIST operator.This policy was introduced in CMake version 3.3.
CMake version 3.10.2 warns when the policy is not set and uses
``OLD`` behavior. Use the ``cmake_policy()`` command to set
it to ``OLD`` or ``NEW`` explicitly... note::
The ``OLD`` behavior of a policy is
``deprecated by definition``
and may be removed in a future version of CMake.支持新的``if()`` IN_LIST操作符。
CMake 3.3增加了对新IN_列表操作符的支持。
此策略的“旧”行为是忽略IN_LIST运算符。
“NEW”行为是解释IN_LIST操作符。
此策略是在CMake 3.3版中引入的。
CMake 3.10.2版在策略未设置和使用时发出警告
``老行为。使用``cmake_policy()``命令设置
它可以显式地转换为“旧”或“新”。
注:
政策的“旧”行为是
``被定义为不推荐``
并可能在未来版本的CMake中删除。
管理员身份登陆:sudo -i
密码是123
使用
nautilus .
打开当前路径文件夹
根据当前路径方法打开Ceres 然后进行修改后出现错误
CMake Error at /usr/local/lib/cmake/Ceres/FindSuiteSparse.cmake:119:
Parse error. Expected a command name, got unquoted argument with text
" cmake_policy".
linux跳出当前命令语句
ctrl+Z
sudo chmod u+w FindSuiteSparse.cmake
使用这个语句加入读写权限 然后打开
没用!!
最后解决办法:
①、先用sudo -i打开管理员模式(不然没法更改文件)
②、进入Ceres路径
③、利用gedit FindSuiteSparse.cmake
用gedit打开这个文件
④、参考这个格式加入这三行 前后都空一行(也不知道为啥)
⑤、保存 关掉终端 重新用普通权限进行run!
打开eclipse 选择File->Import->Existing projects into workspace.
把build文件夹导入
然后安装CDT重启
右键项目选择build project的时候显示没有opencv2 才想起来没搞openCV4.0
---------------------------------------------------------------------------------------------------------------------------------
openCV4.0在Ubuntu的eclipse下安装
参考官方文档 一句句安装 此外还参考了
在 Ubuntu系统下安装 OpenCV 全过程_潇洒过路客的博客-CSDN博客_ubuntu系统安装opencv
找到opencv4.0.0 下载然后移到虚拟机里
Ubuntu右键提取到就是解压操作
linux的cd 后面不用加/ 直接cd build就行 不然显示没找到
直到
sudo make install
完成后,OpenCV 就安装好了,接下来要配置 OpenCV 的编译环境
配置环境成功 但是最后测试
cmake .
make
./opencv_example
的时候报错。
OpenCV Error: Unspecified error (The function is notimplemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. Ifyou are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-runcmake or configure script) in cvNamedWindow, file/home/aborn/software/OpenCV-3.0.0/modules/highgui/src/window.cpp, line …
先不管了
先在ecplise里加入opencv
Using OpenCV with Eclipse (plugin CDT) — OpenCV 2.4.13.7 documentation
发现课设没有
所以建了个新的project试试搭配 发现
pkg-config --cflags opencv
的时候没有结果
Package opencv was not found in the pkg-config search path._Hundreays-CSDN博客
然后就可以了
root@jqx-VirtualBox:/usr/local/lib/pkgconfig# pkg-config --cflags --libs opencv
-I/usr/local/include/opencv4 -L/usr/local/lib -lopencv_shape -lopencv_stitching -lopencv_objdetect -lopencv_superres -lopencv_videostab -lopencv_calib3d -lopencv_features2d -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_video -lopencv_photo -lopencv_ml -lopencv_imgproc -lopencv_flann -lopencv_core
root@jqx-VirtualBox:/usr/local/lib/pkgconfig# pkg-config --cflags --libs opencv
-I/usr/local/include/opencv4 -L/usr/local/lib -lopencv_shape -lopencv_stitching -lopencv_objdetect -lopencv_superres -lopencv_videostab -lopencv_calib3d -lopencv_features2d -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_video -lopencv_photo -lopencv_ml -lopencv_imgproc -lopencv_flann -lopencv_core
其中lib里的jqx@jqx-VirtualBox:~$ pkg-config --libs opencv
-L/usr/local/lib
opencv_shape
opencv_stitching
opencv_objdetect
opencv_superres
opencv_videostab
opencv_calib3d
opencv_features2d
opencv_highgui
opencv_videoio
opencv_imgcodecs
opencv_video
opencv_photo
opencv_ml
opencv_imgproc
opencv_flann
opencv_core
创建了个例子project然后导入了环境变量后 把原来的课设源码删除了 重新import
然后发现build project后没有bug 只有warning 都是一些说没使用到的变量 无所谓
然后run!提示设置参数,应该可以跑了!
2022年3月14日 23:56:00
---------------------------------------------------------------------------------------------------------------------------------
2022年3月17日 14:45:49
经过同组同学指点,发现俩个知识点
1、linux打开文件的话直接终端输入路径+文件名就行
2、打开的命令语句 空一格 然后输入参数就可以带着参数运行文件
/home/jqx/RWHEC-Tabb-AhmadYousef/build/Tabb_AhmadYousef_RWHEC_Jun2018_Project /home/jqx/RWHEC-Tabb-AhmadYousef /home/jqx/RWHEC-Tabb-AhmadYousef
#这里是注释
首先"/home/jqx/RWHEC-Tabb-AhmadYousef/build/Tabb_AhmadYousef_RWHEC_Jun2018_Project”代表我要打开的文件
然后空一格 "/home/jqx/RWHEC-Tabb-AhmadYousef"代表输入目录
再空一格"/home/jqx/RWHEC-Tabb-AhmadYousef"代表输出目录
第三个参数不设置。