我在编译安装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
输出:
-
CXX/LD -o .build_release/tools/convert_annoset.bin
-
CXX/LD -o .build_release/tools/caffe.bin
-
CXX/LD -o .build_release/tools/upgrade_solver_proto_text.bin
-
CXX/LD -o .build_release/tools/compute_image_mean.bin
-
CXX/LD -o .build_release/tools/convert_imageset.bin
-
CXX/LD -o .build_release/tools/create_label_map.bin
-
CXX/LD -o .build_release/tools/upgrade_net_proto_binary.bin
-
CXX/LD -o .build_release/tools/get_image_size.bin
-
//usr/lib/x86_64-linux-gnu/libSM.so.6: undefined reference to `uuid_generate@UUID_1.0
'
-
//usr/lib/x86_64-linux-gnu/libSM.so.6: undefined reference to `uuid_unparse_lower@UUID_1.0'
-
collect2: error: ld returned 1
exit status
-
Makefile:619: recipe
for target
'.build_release/tools/upgrade_solver_proto_text.bin' failed
-
make: *** [.build_release/tools/upgrade_solver_proto_text.bin] Error 1
-
make: *** Waiting
for unfinished
jobs....
-
//usr/lib/x86_64-linux-gnu/libSM.so.6: undefined reference to `uuid_generate@UUID_1.0
'
-
//usr/lib/x86_64-linux-gnu/libSM.so.6: undefined reference to `uuid_unparse_lower@UUID_1.0'
-
collect2: error: ld returned 1
exit status
-
Makefile:619: recipe
for target
'.build_release/tools/convert_imageset.bin' failed
-
make: *** [.build_release/tools/convert_imageset.bin] Error 1
-
//usr/lib/x86_64-linux-gnu/libSM.so.6: undefined reference to `uuid_generate@UUID_1.0
'
-
//usr/lib/x86_64-linux-gnu/libSM.so.6: undefined reference to `uuid_unparse_lower@UUID_1.0'
-
collect2: error: ld returned 1
exit status
-
Makefile:619: recipe
for target
'.build_release/tools/create_label_map.bin' failed
-
make: *** [.build_release/tools/create_label_map.bin] Error 1
-
//usr/lib/x86_64-linux-gnu/libSM.so.6: undefined reference to `uuid_generate@UUID_1.0
'
-
//usr/lib/x86_64-linux-gnu/libSM.so.6: undefined reference to `uuid_unparse_lower@UUID_1.0'
-
collect2: error: ld returned 1
exit status
-
Makefile:619: recipe
for target
'.build_release/tools/convert_annoset.bin' failed
-
make: *** [.build_release/tools/convert_annoset.bin] Error 1
-
//usr/lib/x86_64-linux-gnu/libSM.so.6: undefined reference to `uuid_generate@UUID_1.0
'
-
//usr/lib/x86_64-linux-gnu/libSM.so.6: undefined reference to `uuid_unparse_lower@UUID_1.0'
-
collect2: error: ld returned 1
exit status
-
Makefile:619: recipe
for target
'.build_release/tools/compute_image_mean.bin' failed
-
make: *** [.build_release/tools/compute_image_mean.bin] Error 1
-
//usr/lib/x86_64-linux-gnu/libSM.so.6: undefined reference to `uuid_generate@UUID_1.0
'
-
//usr/lib/x86_64-linux-gnu/libSM.so.6: undefined reference to `uuid_unparse_lower@UUID_1.0'
-
collect2: error: ld returned 1
exit status
-
Makefile:619: recipe
for target
'.build_release/tools/get_image_size.bin' failed
-
make: *** [.build_release/tools/get_image_size.bin] Error 1
-
//usr/lib/x86_64-linux-gnu/libSM.so.6: undefined reference to `uuid_generate@UUID_1.0
'
-
//usr/lib/x86_64-linux-gnu/libSM.so.6: undefined reference to `uuid_unparse_lower@UUID_1.0'
-
collect2: error: ld returned 1
exit status
-
Makefile:619: recipe
for target
'.build_release/tools/upgrade_net_proto_binary.bin' failed
-
make: *** [.build_release/tools/upgrade_net_proto_binary.bin] Error 1
-
//usr/lib/x86_64-linux-gnu/libSM.so.6: undefined reference to `uuid_generate@UUID_1.0
'
-
//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
先查看有什么库,第一个好像可以直接使用
-
(base) jason:~$ apt-cache search libSM
-
libsm-dev - X11 Session Management library (development headers)
-
libsm-doc - documentation
for the X Session Management protocol
and library
-
libsm6 - X11 Session Management library
-
libsm6-dbg - X11 Session Management library (debug package)
-
libsmartcols-dev - smart column output alignment library - headers
and
static libraries
-
libsmartcols1 - smart column output alignment library
-
libsmbclient -
shared library
for communication
with SMB/CIFS servers
-
libsmbclient-dev - development files
for libsmbclient
-
libsmi2-dbg - library
to access SMI MIB information - debugging symbols
-
libsmi2-dev - library
to access SMI MIB information - development files
-
libsmi2ldbl - library
to access SMI MIB information
-
smitools - various tools operating
on MIB
module files
-
libfilesys-smbclient-perl - perl
interface
to access Samba filesystem
-
libsmart-comments-perl - Perl
module
for comments that
do more than just sit there
-
libsmartcardpp-dev - smartcardpp development files
-
libsmartcardpp1 - C++ library
for accessing Smart Cards
-
libsmartcardpp1-dbg - smartcardpp debugging symbols
-
libsmbios-dev - Provide access
to (SM)BIOS information -
2,安装该库(需要root权限)
sudo apt-get insatll libsm-dev
3,查看libSM.so安装位置
ldconfig -p|grep libSM
输出
-
(base)
jason:~
$ ldconfig -p|grep libSM
-
libSM.so.
6 (libc6,x86-
64) =>
/usr/lib
/x86_64-linux-gnu/libSM.so.
6
-
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
输出
-
(base) jason
@jason:
~$ apt
-cache
search uuid
-
golang
-github
-pborman
-uuid
-dev
- Go bindings
to work
with UUIDs
-
golang
-uuid
-dev
- Transitional package
for golang
-github
-pborman
-uuid
-dev
-
jasper
- Configure a preinstalled ext2
/
3
system image
-
libblkid
-dev
- block device ID library
- headers
and
static libraries
-
libblkid1
- block device ID library
-
libuuid
-perl
- Perl extension
for
using UUID interfaces
as defined
in e2fsprogs
-
libuuid1
- Universally
Unique ID library
-
postgresql
-contrib
-9.5
- additional facilities
for PostgreSQL
-
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
输出
-
(base) jason
@jason:~
$ ldconfig -p|grep uuid
-
libuuid.so.
1 (libc6,x86-
64) =>
/lib/x86_64-linux-gnu/libuuid.so.
1
-
libuuid.so (libc6,x86-
64) =>
/usr/lib
/x86_64-linux-gnu/libuuid.so
编译还是报错,查看是不是uuid安装不对导致的
ldd /usr/lib/x86_64-linux-gnu/libSM.so
输出:
(base) jason@jason:~$ ldd /usr/lib/x86_64-linux-gnu/libSM.so linux-vdso.so.1 => (0x00007fffcf9cd000) libICE.so.6 => /usr/lib/x86_64-linux-gnu/libICE.so.6 (0x00007f54c2c89000) libuuid.so.1 => /lib/x86_64-linux-gnu/libuuid.so.1 (0x00007f54c2a84000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f54c26ba000) /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错误的解决方法
其中这句话感觉很重要,
-
另外注意一个问题,就是只要查找到第一个就会返回,后面的不会再查找.
-
比如-L./
A -L./
B -lx 在
A中有libx
.a
B中有libx
.a和libx
.so,
-
这个时候会使用在./
A的libx
.a 而不会遵循动态库优先的原则,
-
因为./
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库文件移走就好了,至此终于解决了这个问题
-
ls ~/anaconda2/lib/libuuid*
-
-
mkdir ~/anaconda2/libuuid
-
-
mv ~/anaconda2/lib/libuuid* ~/anaconda2/libuuid
总结:使用anaconda2一定要注意可能里面的一些库文件并不一定对,下次一定要记得想到这个问题