在编译包含Sophus的源文件的时候,出现如下错误

../lib/libmyslam.so: undefined reference to `Sophus::SO3::SO3(double, double, double)'
../lib/libmyslam.so: undefined reference to `Sophus::SE3::operator*(Eigen::Matrix<double, , , , , > const&) const'
../lib/libmyslam.so: undefined reference to `Sophus::SE3::SE3(Sophus::SO3 const&, Eigen::Matrix<double, , , , , > const&)'
../lib/libmyslam.so: undefined reference to `Sophus::SE3::operator*(Sophus::SE3 const&) const'
../lib/libmyslam.so: undefined reference to `Sophus::SE3::log() const'
../lib/libmyslam.so: undefined reference to `Sophus::SE3::operator=(Sophus::SE3 const&)'
../lib/libmyslam.so: undefined reference to `Sophus::SE3::inverse() const'
../lib/libmyslam.so: undefined reference to `Sophus::SE3::SE3()'
../lib/libmyslam.so: undefined reference to `Sophus::SE3::SE3(Sophus::SE3 const&)'
collect2: error: ld returned exit status

原因分析:
安装Sophus时,有个lib文件“libSophus.so”会出现在/usr/local/lib/libSophus.so
(本人编译时最后执行了 sudo make install, 因此在系统文件夹里面有该lib文件)。
当执行FIND_PACKAGE(sophus REQUIRED)时,libSophus.so 应该被链接到 Sophus_LIBRARIES,
但cmake却没链接上。

决办法:
显式将Sophus_LIBRARIES 链接到libSophus.so,CMakeLists.txt的代码如下:

cmake_minimum_required( VERSION 2.8 )
project( useSophus ) # 为使用 sophus,您需要使用find_package命令找到它
find_package( sophus REQUIRED )
set(Sophus_LIBRARIES "/home/guorun/vision_slam/slambook/3rdparty/Sophus/libSophus.so")
include_directories("/usr/include/eigen3")
include_directories( ${Sophus_INCLUDE_DIRS} ) add_executable( useSophus useSophus.cpp )
target_link_libraries( useSophus ${Sophus_LIBRARIES} )

即可成功。

以上使用的是老版本的Sophus,新版本的还未测试!!!

Sophus libSophus.so的更多相关文章

  1. cmake find_package 中,include_directories,target_link_libraries 的值怎么知道?

    拿Sophus库为例: find_package(Sophus REQUIRED) include_directories(${Sophus_INCLUDE_DIRS}) target_link_li ...

  2. Sophus链接错误

    错误指示如下: CMakeFiles/run_vo.dir/run_vo.cpp.o: In function `main': run_vo.cpp:(.text.startup+0x1086): u ...

  3. Sophus库CMakeLists.txt内容详解笔记

    CMakeLists.txt: SET(PROJECT_NAME Sophus) PROJECT(${PROJECT_NAME}) CMAKE_MINIMUM_REQUIRED(VERSION 2.6 ...

  4. Could not find a package configuration file provided by "Sophus",SophusConfig.cmake

    CMake Error at CMakeLists.txt:5 (find_package): By not providing "FindSophus.cmake" in CMA ...

  5. ubuntu16.04下安装Sophus

    git clone https://github.com/strasdat/Sophus.git 下载完成后 cd Sophus git checkout a621ffmkdir buildcd bu ...

  6. Sophus VS2010编译不支持?C++11语法的缘故。那有没有不带C++11特性的Sophus版本呢?

    Eigen:3.1 3.0 Ceres:No Sophus: Sophus支不支持Windows编译?官网写的是通过了Windows的编译的 linux, os x:  windows:  code ...

  7. 使用Sophus练习李群SO3、SE3以及对应的李代数so3、se3

    这是高博<视觉SLAM14讲,从理论到实践>第4章的练习.加了一些注释和理解: #include <iostream>#include <cmath>using n ...

  8. SLAM十四讲中Sophus库安装

    Sophus截止目前有很多版本,其中大体分为两类,一种是用模板实现的方法,一种是用非模板类实现的,SLAM十四讲中使用的是非模板类库,clone Sophus: git clone http://gi ...

  9. 如何安装Eigen库和Sophus库

    * { font-family: "Tibetan Machine Uni", "sans-serif", STFangSong; outline: none ...

随机推荐

  1. spring boot 微服务例子一

    package com.example.hello.demo; import org.springframework.boot.SpringApplication;import org.springf ...

  2. jquery使用post方法传值

    1.js代码 <script type="text/javascript"> function addSku(skuId){ var m = $("#m&qu ...

  3. 五、Singleton 单例模式

    需求:保证对象只创建一次 说明: 分为懒汉式.饿汉式,通过是否一开始就创建静态对象.饿汉式需要考虑线程并发的安全 懒汉式: public class Singleton { private stati ...

  4. iOS8不能通过itms-services协议下载安装app

    问题:iOS包通过itms-services协议下载app无反应   使用  itms-services://?action=download-manifest&url=[ipa下载链接] 下 ...

  5. GsonFormat的使用 (转)

    一.Android Studio快速添加Gson 具体操作:        1.File->Project Structure:   2.app->Dependencies->&qu ...

  6. spring jpa nativequery in与修改

    参考 https://blog.csdn.net/a3025056/article/details/79022816 @Modifying@Transactional /* 如果在事务中使用需加上此注 ...

  7. C# sqlserver ExecuteNonQuery()方法详解

    关于ExecuteNonQuery() 方法以前对这个一直都没在意,基本上都没有用其返回值,查了一下MSDN,如下:SqlCommand.ExecuteNonQuery 方法对连接执行 Transac ...

  8. css设置input不显示光标

    把光标颜色设置为透明色和父类一样就看不出来了,就好像取消了 caret-color: transparent; 设置了这个属性后,无论如何点击都好像没有光标似的

  9. 颜色 color

    在res/values文件夹下的color.xml添加 <?xml version="1.0" encoding="utf-8"?> <res ...

  10. ASP.Net MVC 在ajax接收controller返回值为Json数据

    首先,再次回忆一下ajax的标准用法:(这张图写的比较详细了)(转) 页面部分ajax代码: $.ajax({            url: "/Home/Login?account=&q ...