libgflags.so.2.2以及glog.so编译报错 cannot open shared object file/symbol lookup error解决办法

报错信息分别是:
./curve_fitting: error while loading shared libraries: libgflags.so.2.2: cannot open shared object file: No such file or directory 

和 

./curve_fitting: symbol lookup error: /usr/local/lib/libglog.so.0: undefined symbol: _ZN6google14FlagRegistererC1ISsEEPKcS3_S3_PT_S5_ 

—————————————————————————————————————————— 
在学习《SLAM 十四讲》第六讲的过程中,学习ceres的使用,但是安装之后总是报错:

报错(1)如下:

./curve_fitting: error while loading shared libraries: libgflags.so.2.2: cannot open shared object file: No such file or directory 

而且这是我编译都是通过的,而且生成了可执行文件,但是就是提醒了这个错误, 
然后尝试:sudo apt-get install libglags但是还是无效,显示我已经安装过了!

报错(1)解决办法:
Step1:

 $ git clone https://github.com/gflags/gflags

Step2:

 $ cd gflags
 $ mkdir build
 $ cd build

Step3(重要):

$ cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_SHARED_LIBS=ON -DGFLAGS_NAMESPACE=google -G"Unix Makefiles" ..

$ make -j4

发现make之后给的反馈信息如下:
Scanning dependencies of target gflags_shared
Scanning dependencies of target gflags_nothreads_shared
[ 37%] Building CXX object CMakeFiles/gflags_nothreads_shared.dir/src/gflags_reporting.cc.o
[ 37%] Building CXX object CMakeFiles/gflags_shared.dir/src/gflags.cc.o
[ 37%] Building CXX object CMakeFiles/gflags_shared.dir/src/gflags_reporting.cc.o
[ 50%] Building CXX object CMakeFiles/gflags_nothreads_shared.dir/src/gflags.cc.o
[ 62%] Building CXX object CMakeFiles/gflags_shared.dir/src/gflags_completions.cc.o
[ 75%] Building CXX object CMakeFiles/gflags_nothreads_shared.dir/src/gflags_completions.cc.o
[ 87%] Linking CXX shared library lib/libgflags_nothreads.so
[100%] Linking CXX shared library lib/libgflags.so
[100%] Built target gflags_nothreads_shared
[100%] Built target gflags_shared

这个其实已经有点开心了,因为看到了libgflags.so了,说明共享库成功生成了! 
继续输入

$ sudo make install

看到的反馈信息如下:
[ 50%] Built target gflags_nothreads_shared
[100%] Built target gflags_shared
Install the project...
-- Install configuration: "Release"
-- Installing: /usr/local/lib/libgflags.so.2.2.1
-- Installing: /usr/local/lib/libgflags.so.2.2
-- Installing: /usr/local/lib/libgflags.so
-- Installing: /usr/local/lib/libgflags_nothreads.so.2.2.1
-- Installing: /usr/local/lib/libgflags_nothreads.so.2.2
-- Installing: /usr/local/lib/libgflags_nothreads.so
-- Installing: /usr/local/include/gflags/gflags.h
-- Installing: /usr/local/include/gflags/gflags_declare.h
-- Installing: /usr/local/include/gflags/gflags_completions.h
-- Installing: /usr/local/lib/cmake/gflags/gflags-config.cmake
-- Installing: /usr/local/lib/cmake/gflags/gflags-config-version.cmake
-- Old export file "/usr/local/lib/cmake/gflags/gflags-targets.cmake" will be replaced.  Removing files [/usr/local/lib/cmake/gflags/gflags-targets-release.cmake].
-- Installing: /usr/local/lib/cmake/gflags/gflags-targets.cmake
-- Installing: /usr/local/lib/cmake/gflags/gflags-targets-release.cmake
-- Up-to-date: /usr/local/bin/gflags_completions.sh
-- Installing: /usr/local/lib/pkgconfig/gflags.pc
-- Installing: /home/hri/.cmake/packages/gflags/e5f7ce61772240490d3164df06f58ce9

好了还有最后一步:

Step4:

$ sudo ldconfig

这个的意思就是加载动态链接库,一般是编译安装软件时候出现动态链接库报错需要手动加载下! 
好了,再去执行程序,发现这个上面第一个报错没有了,但是又出现了第二个报错: 
————————————————————————————————————————————

报错(2)

./curve_fitting: symbol lookup error: /usr/local/lib/libglog.so.0: undefined symbol: _ZN6google14FlagRegistererC1ISsEEPKcS3_S3_PT_S5_ 

这个时候发现,原来和上面那个gflag是一毛一样的错误!那就继续照猫画虎修改!

报错(2)解决办法
Step1:获取glog

$ git clone https://github.com/google/glog

Step2:编译glog
依次执行一下命令,(每行是一个单独命令!)

$ cd glog
$ ./autogen.sh
$ sudo CFLAGS="-fPIC" ./configure
$ mkdri build
$ cd build
$ cmake -D BUILD_gflags_LIBS=ON  -D BUILD_SHARED_LIBS=ON -D BUILD_gflags_nothreads_LIBS=ON -D GFLAGS_NAMESPACE=ON ..
$ make -j4
$ sudo make install

—————————————————————————————————————————————————————— 
好的,完美解决了!也看到了libglog.so的共享库了! 
 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值