这里写自定义目录标题
- 写在前面
- 1、安装指令:
- 2、编译过程中出现的问题及解决办法:
- 问题1:
- 问题2:
- 3.使用过程中出现的问题
- 参考链接
写在前面
本文转载自:
[1] haxiongha. ubuntu下安装Sophus库出现问题及解决办法 [EB/OL]. https://blog.csdn.net/haxiongha/article/details/82464148
Sophus库是一个较好的李群李代数库,此处安装的是非模板类的Sophus库。具体安装过程如下:
1、安装指令:
1
2
3
4
5
6
7
8
9git clone https://github.com/strasdat/Sophus.git cd Sophus/ git checkout a621ff mkdir build cd build cmake .. make
2、编译过程中出现的问题及解决办法:
问题1:
1
2
3
4
5
6/Sophus/sophus/so2.cpp:32:26: error: lvalue required as left operand of assignment unit_complex_.real() = 1.; /Sophus/sophus/so2.cpp:33:26: error: lvalue required as left operand of assignment unit_complex_.imag() = 0.;
该错误可以定位到so2.cpp源码文件下:
将
1
2
3
4
5
6SO2::SO2() { unit_complex_.real() = 1.; unit_complex_.imag() = 0.; }
修改为
1
2
3
4
5
6
7
8SO2::SO2() { //unit_complex_.real() = 1.; //unit_complex_.imag() = 0.; unit_complex_.real(1.); unit_complex_.imag(0.); }
问题2:
1
2
3
4/home/tympn/workspace/slam/practice/Sophus/sophus/so2.cpp:83:67: required from here /usr/include/eigen3/Eigen/src/Core/AssignEvaluator.h:86:63: ***error: enum constant in boolean context [-Werror=int-in-bool-context] MayLinearVectorize = bool(MightVectorize) && MayLinearize && DstHasDirectAccess***
这类错误有很多,就不一一列举,只贴其中一条
该错误可以定位到eigen库下的AssignEvaluator.h文件,为了修复gcc7的警告问题,对该文件已做了如下修改:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17enum { DstAlignment = DstEvaluator::Alignment, SrcAlignment = SrcEvaluator::Alignment, - DstHasDirectAccess = DstFlags & DirectAccessBit, + DstHasDirectAccess = (DstFlags & DirectAccessBit) == DirectAccessBit, JointAlignment = EIGEN_PLAIN_ENUM_MIN(DstAlignment,SrcAlignment) }; && int(OuterStride)!=Dynamic && int(OuterStride)%int(InnerPacketSize)==0 && (EIGEN_UNALIGNED_VECTORIZE || int(JointAlignment)>=int(InnerRequiredAlignment)), MayLinearize = bool(StorageOrdersAgree) && (int(DstFlags) & int(SrcFlags) & LinearAccessBit), - MayLinearVectorize = bool(MightVectorize) && MayLinearize && DstHasDirectAccess + MayLinearVectorize = bool(MightVectorize) && bool(MayLinearize) && bool(DstHasDirectAccess) && (EIGEN_UNALIGNED_VECTORIZE || (int(DstAlignment)>=int(LinearRequiredAlignment)) || MaxSizeAtCompileTime == Dynamic), /* If the destination isn't aligned, we have to do runtime checks and we don't unroll, so it's only good for large enough sizes. */
其中加号行代码替换减号行
参考源:https://bitbucket.org/eigen/eigen/commits/b4f969795d1b0adbb43ebdd8c6bbcb42cb559687?at=3.3
3.使用过程中出现的问题
该库的使用可以安装也可以不安装,这里建议安装,因为只有安装后在阅读源码时才可以跳转到该库的头文件。
不论安不安装,均可以使用下列方式编译调用该库
1
2
3
4
5
6
7
8
9cmake_minimum_required( VERSION 2.8 ) project( useSophus ) set(CMAKE_BUILD_TYPE "Release") # 为使用 sophus,您需要使用find_package命令找到它 find_package( Sophus REQUIRED ) include_directories( ${Sophus_INCLUDE_DIRS} ) add_executable( useSophus useSophus.cpp ) target_link_libraries( useSophus ${Sophus_LIBRARIES})
这里有个坑需要注意:(但是自己没有遇到这个问题)
1
2set(CMAKE_BUILD_TYPE "Release")
这条语句不能少,少了后,代码可以正常编译生成可执行文件,但是在运行可执行文件时会出现如下错误:
1
2
3
4
5
6useSophus: /usr/include/eigen3/Eigen/src/Core/PlainObjectBase.h:285: void Eigen::PlainObjectBase<Derived>::resize(Eigen::Index, Eigen::Index) [with Derived = Eigen:: Matrix<double, 3, 1>; Eigen::Index = long int]: Assertion `(!(RowsAtCompileTime!=Dynamic) || (rows==RowsAtCompileTime)) && (!(ColsAtCompileTime!=Dynamic) || (cols==C olsAtCompileTime)) && (!(RowsAtCompileTime==Dynamic && MaxRowsAtCompileTime!=Dynamic) || (rows<=MaxRowsAtCompileTime)) && (!(ColsAtCompileTime==Dynamic && MaxColsAtC ompileTime!=Dynamic) || (cols<=MaxColsAtCompileTime)) && rows>=0 && cols>=0 && "Invalid sizes when resizing a matrix or array."' failed. Aborted (core dumped)
这是因为该库不支持Debug模式
注意:如果不使用CMAKE_BUILD_TYPE参数,则默认是Debug
参考链接
[1] haxiongha. ubuntu下安装Sophus库出现问题及解决办法 [EB/OL]. https://blog.csdn.net/haxiongha/article/details/82464148
最后
以上就是隐形自行车最近收集整理的关于《视觉SLAM十四讲》第四讲-ubuntu下安装Sophus库出现问题及解决办法写在前面1、安装指令:2、编译过程中出现的问题及解决办法:3.使用过程中出现的问题参考链接的全部内容,更多相关《视觉SLAM十四讲》第四讲-ubuntu下安装Sophus库出现问题及解决办法写在前面1、安装指令:2、编译过程中出现内容请搜索靠谱客的其他文章。
发表评论 取消回复