我正在运行此命令 -
/usr/bin/c++ CMakeFiles/XYZ.dir/test/XYZ.cpp.o CMakeFiles/XYZ.dir/test/TempDir.cpp.o
-o XYZ libXYZMaster.so -lboost_filesystem -lboost_system
/usr/lib/x86_64-linux-gnu/libboost_unit_test_framework.so -lboost_random
-lboost_iostreams -lboost_thread -ldw -lunwind
-Wl,-rpath,/home/user885/untitled/build
但我收到此链接器错误 -
libXYZMaster.so: undefined reference to `_Ux86_64_step'
libXYZMaster.so: undefined reference to `_Ux86_64_init_local'
libXYZMaster.so: undefined reference to `_Ux86_64_get_proc_name'
libXYZMaster.so: undefined reference to `_Ux86_64_get_reg'
当我做nm -D时,我确实看到了定义的符号 -
$ nm -D /usr/lib/x86_64-linux-gnu/libunwind.so | grep -P "_step|init_local|get_proc_name|get_reg"
00000000000031d0 T _ULx86_64_get_proc_name
0000000000003370 T _ULx86_64_get_reg
0000000000004510 T _ULx86_64_init_local
0000000000004d20 T _ULx86_64_step
此外,libXYZMaster.so的ldd表明libunwind已链接 -
linux-vdso.so.1 => (0x00007ffd58f4a000)
libdw.so.1 => /usr/lib/x86_64-linux-gnu/libdw.so.1 (0x00007ff614bac000)
libunwind.so.8 => /usr/lib/x86_64-linux-gnu/libunwind.so.8 (0x00007ff614991000)
libboost_system.so.1.58.0 => /usr/lib/x86_64-linux-gnu/libboost_system.so.1.58.0 (0x00007ff61478d000)
libboost_filesystem.so.1.58.0 => /usr/lib/x86_64-linux-gnu/libboost_filesystem.so.1.58.0 (0x00007ff614575000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007ff6141ec000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007ff613e22000)
libelf.so.1 => /usr/lib/x86_64-linux-gnu/libelf.so.1 (0x00007ff613c0a000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007ff613a06000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007ff6137ec000)
liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007ff6135ca000)
libbz2.so.1.0 => /lib/x86_64-linux-gnu/libbz2.so.1.0 (0x00007ff6133ba000)
/lib64/ld-linux-x86-64.so.2 (0x00007ff615084000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007ff61319d000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007ff612f86000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007ff612c7d000)
答案 0 :(得分:3)
为了将来参考,这是因为在包含之前我没有#defined UNW_LOCAL_ONLY ...保留未定义导致不同的函数签名被选中(或许随机)。