解决caffe编译时//usr/lib/x86_64-linux-gnu/libSM.so.6: undefined reference to `uuid_unparse_lower@UUI

我在编译安装RefineDet的caffe版遇到//usr/lib/x86_64-linux-gnu/libSM.so.6: undefined reference to `uuid_unparse_lower@UUID_1.0'

我的编译环境时anaconda2,python2.7,ubuntu16.04

RefineDet$ make -j8
   
   

输出:


   
   
  1. CXX/LD -o .build_release/tools/convert_annoset.bin
  2. CXX/LD -o .build_release/tools/caffe.bin
  3. CXX/LD -o .build_release/tools/upgrade_solver_proto_text.bin
  4. CXX/LD -o .build_release/tools/compute_image_mean.bin
  5. CXX/LD -o .build_release/tools/convert_imageset.bin
  6. CXX/LD -o .build_release/tools/create_label_map.bin
  7. CXX/LD -o .build_release/tools/upgrade_net_proto_binary.bin
  8. CXX/LD -o .build_release/tools/get_image_size.bin
  9. //usr/lib/x86_64-linux-gnu/libSM.so.6: undefined reference to `uuid_generate@UUID_1.0 '
  10. //usr/lib/x86_64-linux-gnu/libSM.so.6: undefined reference to `uuid_unparse_lower@UUID_1.0'
  11. collect2: error: ld returned 1 exit status
  12. Makefile:619: recipe for target '.build_release/tools/upgrade_solver_proto_text.bin' failed
  13. make: *** [.build_release/tools/upgrade_solver_proto_text.bin] Error 1
  14. make: *** Waiting for unfinished jobs....
  15. //usr/lib/x86_64-linux-gnu/libSM.so.6: undefined reference to `uuid_generate@UUID_1.0 '
  16. //usr/lib/x86_64-linux-gnu/libSM.so.6: undefined reference to `uuid_unparse_lower@UUID_1.0'
  17. collect2: error: ld returned 1 exit status
  18. Makefile:619: recipe for target '.build_release/tools/convert_imageset.bin' failed
  19. make: *** [.build_release/tools/convert_imageset.bin] Error 1
  20. //usr/lib/x86_64-linux-gnu/libSM.so.6: undefined reference to `uuid_generate@UUID_1.0 '
  21. //usr/lib/x86_64-linux-gnu/libSM.so.6: undefined reference to `uuid_unparse_lower@UUID_1.0'
  22. collect2: error: ld returned 1 exit status
  23. Makefile:619: recipe for target '.build_release/tools/create_label_map.bin' failed
  24. make: *** [.build_release/tools/create_label_map.bin] Error 1
  25. //usr/lib/x86_64-linux-gnu/libSM.so.6: undefined reference to `uuid_generate@UUID_1.0 '
  26. //usr/lib/x86_64-linux-gnu/libSM.so.6: undefined reference to `uuid_unparse_lower@UUID_1.0'
  27. collect2: error: ld returned 1 exit status
  28. Makefile:619: recipe for target '.build_release/tools/convert_annoset.bin' failed
  29. make: *** [.build_release/tools/convert_annoset.bin] Error 1
  30. //usr/lib/x86_64-linux-gnu/libSM.so.6: undefined reference to `uuid_generate@UUID_1.0 '
  31. //usr/lib/x86_64-linux-gnu/libSM.so.6: undefined reference to `uuid_unparse_lower@UUID_1.0'
  32. collect2: error: ld returned 1 exit status
  33. Makefile:619: recipe for target '.build_release/tools/compute_image_mean.bin' failed
  34. make: *** [.build_release/tools/compute_image_mean.bin] Error 1
  35. //usr/lib/x86_64-linux-gnu/libSM.so.6: undefined reference to `uuid_generate@UUID_1.0 '
  36. //usr/lib/x86_64-linux-gnu/libSM.so.6: undefined reference to `uuid_unparse_lower@UUID_1.0'
  37. collect2: error: ld returned 1 exit status
  38. Makefile:619: recipe for target '.build_release/tools/get_image_size.bin' failed
  39. make: *** [.build_release/tools/get_image_size.bin] Error 1
  40. //usr/lib/x86_64-linux-gnu/libSM.so.6: undefined reference to `uuid_generate@UUID_1.0 '
  41. //usr/lib/x86_64-linux-gnu/libSM.so.6: undefined reference to `uuid_unparse_lower@UUID_1.0'
  42. collect2: error: ld returned 1 exit status
  43. Makefile:619: recipe for target '.build_release/tools/upgrade_net_proto_binary.bin' failed
  44. make: *** [.build_release/tools/upgrade_net_proto_binary.bin] Error 1
  45. //usr/lib/x86_64-linux-gnu/libSM.so.6: undefined reference to `uuid_generate@UUID_1.0 '
  46. //usr/lib/x86_64-linux-gnu/libSM.so.6: undefined reference to `uuid_unparse_lower@UUID_1.0'

解决办法:缺少libSM.so库文件,因此安装即可,可以直接看最后终极大法

1,查询limSM库安装包名字

apt-cache search libSM
   
   

先查看有什么库,第一个好像可以直接使用


   
   
  1. (base) jason:~$ apt-cache search libSM
  2. libsm-dev - X11 Session Management library (development headers)
  3. libsm-doc - documentation for the X Session Management protocol and library
  4. libsm6 - X11 Session Management library
  5. libsm6-dbg - X11 Session Management library (debug package)
  6. libsmartcols-dev - smart column output alignment library - headers and static libraries
  7. libsmartcols1 - smart column output alignment library
  8. libsmbclient - shared library for communication with SMB/CIFS servers
  9. libsmbclient-dev - development files for libsmbclient
  10. libsmi2-dbg - library to access SMI MIB information - debugging symbols
  11. libsmi2-dev - library to access SMI MIB information - development files
  12. libsmi2ldbl - library to access SMI MIB information
  13. smitools - various tools operating on MIB module files
  14. libfilesys-smbclient-perl - perl interface to access Samba filesystem
  15. libsmart-comments-perl - Perl module for comments that do more than just sit there
  16. libsmartcardpp-dev - smartcardpp development files
  17. libsmartcardpp1 - C++ library for accessing Smart Cards
  18. libsmartcardpp1-dbg - smartcardpp debugging symbols
  19. libsmbios-dev - Provide access to (SM)BIOS information -

2,安装该库(需要root权限)

sudo apt-get insatll libsm-dev
   
   

3,查看libSM.so安装位置

ldconfig -p|grep libSM
   
   

输出


   
   
  1. (base) jason:~ $ ldconfig -p|grep libSM
  2. libSM.so. 6 (libc6,x86- 64) => /usr/lib /x86_64-linux-gnu/libSM.so. 6
  3. libSM.so (libc6,x86- 64) => /usr/lib /x86_64-linux-gnu/libSM.so

所以/usr/lib/x86_64-linux-gnu应该要放在LD_LIBRARY_PATH环境变量里面,但是在我这没有解决问题,

(可选)大家可以尝试下面的方法看能否解决你的问题:

vim ~/.bashrc
   
   

在文件中写入

export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/:$LD_LIBRARY_PATH
   
   

然后让其生效

source ~/.bashrc
   
   

4,上面方法没有生效,我想是不是我的库链接有问题

ldd /usr/lib/x86_64-linux-gnu/libSM.so
   
   

报libuuid链接库有问题,因此需要安装uuid,

5,安装uuid

1)搜索库文件名字

apt-cache search uuid
   
   

输出


   
   
  1. (base) jason @jason: ~$ apt -cache search uuid
  2. golang -github -pborman -uuid -dev - Go bindings to work with UUIDs
  3. golang -uuid -dev - Transitional package for golang -github -pborman -uuid -dev
  4. jasper - Configure a preinstalled ext2 / 3 system image
  5. libblkid -dev - block device ID library - headers and static libraries
  6. libblkid1 - block device ID library
  7. libuuid -perl - Perl extension for using UUID interfaces as defined in e2fsprogs
  8. libuuid1 - Universally Unique ID library
  9. postgresql -contrib -9.5 - additional facilities for PostgreSQL
  10. uuid -dev - Universally Unique ID library - headers and static libraries

uuid-dev这个库有头文件和静态库,所以安装uuid-dev

2)安装库文件

sudo apt-get install uuid-dev
   
   

3)查看库文件所在路径

ldconfig -p|grep uuid 
   
   

输出


   
   
  1. (base) jason @jason:~ $ ldconfig -p|grep uuid
  2.     libuuid.so. 1 (libc6,x86- 64) => /lib/x86_64-linux-gnu/libuuid.so. 1
  3.     libuuid.so (libc6,x86- 64) => /usr/lib /x86_64-linux-gnu/libuuid.so

编译还是报错,查看是不是uuid安装不对导致的

ldd /usr/lib/x86_64-linux-gnu/libSM.so
   
   

输出:


   
   
  1. (base) jason@jason:~$ ldd /usr/lib/x86_64-linux-gnu/libSM.so
  2. linux-vdso.so.1 => (0x00007fffcf9cd000)
  3. libICE.so.6 => /usr/lib/x86_64-linux-gnu/libICE.so.6 (0x00007f54c2c89000)
  4. libuuid.so.1 => /lib/x86_64-linux-gnu/libuuid.so.1 (0x00007f54c2a84000)
  5. libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f54c26ba000)
  6. /lib64/ld-linux-x86-64.so.2 (0x00007f54c30ab000)

看来现在正常了,但问题并没有解决,还是报//usr/lib/x86_64-linux-gnu/libSM.so.6: undefined reference to `uuid_unparse_lower@UUID_1.0',要崩溃了,太难解决了,后来想直接搜索undefined reference,看看这个是什么问题

果然这是一个c++编译常见错误

可以参考一下这些文章undefined reference to错误的解决方法

其中这句话感觉很重要,


   
   
  1. 另外注意一个问题,就是只要查找到第一个就会返回,后面的不会再查找.
  2. 比如-L./ A -L./ B -lx 在 A中有libx .a B中有libx .a和libx .so,
  3. 这个时候会使用在./ A的libx .a 而不会遵循动态库优先的原则,
  4. 因为./ A是先找到的,并且没有同名动态库存在

【注】链接时顺序不对会报这个错,按道理caffe自己写的脚本编译顺序应该不会有问题,于是我想到是不是使用anaconda2环境时会先搜索anaconda2/lib里面的库文件导致的,当搜到了就不在使用刚才新装的uuid库文件了,去这个文件下面查看果真有这个libuuid

 

由于我的~/.bashrc里面把anaconda2//lib加入了LD_LIBRARY_PATH里面,这里面有libuuid.so库文件,搜索时先搜索了这里面的库文件,但该库文件好像有问题,因此移除即可

[注]在第三步可选里面我把/usr/lib/x86_64-linux-gnu加入动态链接库LD_LIBRARY_PATH,后来发现把这个路径删掉好像也可以

6,终极大法出现:把anaconda2/lib下的libuuid库文件移走就好了,至此终于解决了这个问题


   
   
  1. ls ~/anaconda2/lib/libuuid*
  2. mkdir ~/anaconda2/libuuid
  3. mv ~/anaconda2/lib/libuuid* ~/anaconda2/libuuid

 

 

总结:使用anaconda2一定要注意可能里面的一些库文件并不一定对,下次一定要记得想到这个问题

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值