对 std::runtime_error::operator= 的未定义引用

Undefined reference to std::runtime_error::operator=

提问人:jjcasmar 提问时间:8/2/2019 最后编辑:jjcasmar 更新时间:8/2/2019 访问量:4839

问:

我在尝试链接项目时遇到问题。它给了我以下输出

[100%] Linking CXX executable ../../bin/deSimViewer
/usr/bin/ld: ../../lib/libdeViewerCore.so: undefined reference to `std::runtime_error::operator=(std::runtime_error&&)'

deSimViewer是配置了 cmake 的目标,它仅链接到 .deViewerCore

我正在做,得到以下输出(裁剪以仅显示有趣的部分)ldd deViewerCore.so

        libcusparse.so.10 => /opt/cuda/lib64/libcusparse.so.10 (0x00007efbeea42000)
        libdl.so.2 => /usr/lib/libdl.so.2 (0x00007efbeea3d000)
        libgomp.so.1 => /usr/lib/libgomp.so.1 (0x00007efbeea02000)
        libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007efbee9e1000)
        libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007efbee7f9000)
        libm.so.6 => /usr/lib/libm.so.6 (0x00007efbee6b3000)
        libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007efbee699000)
        libc.so.6 => /usr/lib/libc.so.6 (0x00007efbee4d6000)

所以它与 .libstdc++.so.6

nm -C /usr/lib/libstdc++.so.6 | grep runtime_error显示存在operator=

00000000000c9290 T std::runtime_error::operator=(std::runtime_error&&)
00000000000c9240 T std::runtime_error::operator=(std::runtime_error const&)

所以我不知道这是怎么回事,也不知道为什么它没有链接。

知道可能会发生什么吗?

编辑:按照评论中的建议添加nm的输出而不进行去边角

nm libdeViewerCore.so | grep runtime_error

                 U _ZNKSt13runtime_error4whatEv@@GLIBCXX_3.4
                 U _ZNSt13runtime_erroraSEOS_
                 U _ZNSt13runtime_errorC1EPKc@@GLIBCXX_3.4.21
                 U _ZNSt13runtime_errorC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE@@GLIBCXX_3.4.21
                 U _ZNSt13runtime_errorC2EPKc@@GLIBCXX_3.4.21
                 U _ZNSt13runtime_errorC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE@@GLIBCXX_3.4.21
                 U _ZNSt13runtime_errorC2ERKS_@@GLIBCXX_3.4.21
                 U _ZNSt13runtime_errorD1Ev@@GLIBCXX_3.4
                 U _ZNSt13runtime_errorD2Ev@@GLIBCXX_3.4
                 U _ZTISt13runtime_error@@GLIBCXX_3.4

nm /usr/lib/libstdc++.so.6 | grep runtime_error

00000000000c9650 t _Z28_txnal_runtime_error_get_msgPv
00000000000c9f80 T _ZGTtNKSt13runtime_error4whatEv
00000000000c9e00 T _ZGTtNSt13runtime_errorC1EPKc
0000000000097bfb t _ZGTtNSt13runtime_errorC1EPKc.cold
00000000000c9ea0 T _ZGTtNSt13runtime_errorC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
0000000000097c0d t _ZGTtNSt13runtime_errorC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE.cold
00000000000c9e00 T _ZGTtNSt13runtime_errorC2EPKc
00000000000c9ea0 T _ZGTtNSt13runtime_errorC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
00000000000c9f60 T _ZGTtNSt13runtime_errorD0Ev
00000000000c9f40 T _ZGTtNSt13runtime_errorD1Ev
00000000000c9f40 T _ZGTtNSt13runtime_errorD2Ev
00000000000b8610 T _ZNKSt13runtime_error4whatEv
00000000000c9290 T _ZNSt13runtime_erroraSEOS_
00000000000c9240 T _ZNSt13runtime_erroraSERKS_
00000000000c9260 T _ZNSt13runtime_errorC1EOS_
00000000000c93a0 T _ZNSt13runtime_errorC1EPKc
00000000000d9a60 T _ZNSt13runtime_errorC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
00000000000c9210 T _ZNSt13runtime_errorC1ERKS_
00000000000b8a20 T _ZNSt13runtime_errorC1ERKSs
00000000000c9260 T _ZNSt13runtime_errorC2EOS_
00000000000c93a0 T _ZNSt13runtime_errorC2EPKc
0000000000097acc t _ZNSt13runtime_errorC2EPKc.cold
00000000000d9a60 T _ZNSt13runtime_errorC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
000000000009925a t _ZNSt13runtime_errorC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE.cold
00000000000c9210 T _ZNSt13runtime_errorC2ERKS_
00000000000b8a20 T _ZNSt13runtime_errorC2ERKSs
0000000000096332 t _ZNSt13runtime_errorC2ERKSs.cold
00000000000b8880 T _ZNSt13runtime_errorD0Ev
00000000000b87e0 T _ZNSt13runtime_errorD1Ev
00000000000b87e0 T _ZNSt13runtime_errorD2Ev
0000000000098443 T _ZSt21__throw_runtime_errorPKc
00000000001da4a0 V _ZTISt13runtime_error
000000000018f560 V _ZTSSt13runtime_error
00000000001da5c8 V _ZTVSt13runtime_error

看起来有些名称有所不同:@@GLIBCXX_3.4

编辑:显示完整的链接器命令

/home/jjcasmar/usr/local/bin/c++   -fopenmp -g -DDEBUG   CMakeFiles/deSimViewer.dir/deSimViewer_autogen/mocs_compilation.cpp.o CMakeFiles/deSimViewer.dir/main.cpp.o CMakeFiles/deSimViewer.dir/MainWindow.cpp.o  -o ../../bin/deSimViewer  -L/opt/cuda/targets/x86_64-linux/lib/stubs  -L/opt/cuda/targets/x86_64-linux/lib -Wl,-rpath,/home/jjcasmar/projects/Desilico/prj/Debug/lib:/opt/Qt/5.12.4/gcc_64/lib:/home/jjcasmar/projects/Desilico/External/usr/local/lib:/opt/cuda/lib64/stubs:/opt/cuda/lib64 ../../lib/libdeViewerCore.so /opt/Qt/5.12.4/gcc_64/lib/libQt5Widgets.so.5.12.4 /opt/Qt/5.12.4/gcc_64/lib/libQt53DExtras.so.5.12.4 /opt/Qt/5.12.4/gcc_64/lib/libQt53DRender.so.5.12.4 /opt/Qt/5.12.4/gcc_64/lib/libQt53DLogic.so.5.12.4 /opt/Qt/5.12.4/gcc_64/lib/libQt53DInput.so.5.12.4 /opt/Qt/5.12.4/gcc_64/lib/libQt53DCore.so.5.12.4 /opt/Qt/5.12.4/gcc_64/lib/libQt5Network.so.5.12.4 /opt/Qt/5.12.4/gcc_64/lib/libQt5Gamepad.so.5.12.4 /opt/usr/local/lib64/libfmt.a ../../lib/libdeSim.a /opt/Qt/5.12.4/gcc_64/lib/libQt5Gui.so.5.12.4 /opt/Qt/5.12.4/gcc_64/lib/libQt5Core.so.5.12.4 ../../lib/libdeGeom.a ../../lib/libdeCore.a ../../lib/libdeGeom.a ../../lib/libdeCore.a /usr/lib/libCGAL.so.13.0.3 /usr/lib/libmpfr.so /usr/lib/libgmp.so ../../../../External/usr/local/lib/libOpenMeshTools.so ../../../../External/usr/local/lib/libOpenMeshCored.so ../../../../External/usr/local/lib/libOpenMeshToolsd.so /usr/lib/libosdCPU.so ../../../../External/lib/Debug/libmongocxx-static_debug.a ../../../../External/lib/Debug/libbsoncxx-static_debug.a ../../../../External/lib/Release/libmongoc-static-1.0.a ../../../../External/lib/Debug/libbson-static-1.0_debug.a ../../../../External/usr/local/lib64/libpugixml_debug.a /opt/cuda/lib64/stubs/libnvidia-ml.so /usr/lib/libEGL.so /usr/lib/libOpenGL.so -lstdc++fs -lssl -lcrypto -lcrypt -lresolv -lz -lrt /opt/cuda/lib64/libcudart.so ../../../../External/lib/Debug/libOpenVDB_debug.a ../../../../External/boost/stage/lib/libboost_system-mt-sd.a ../../../../External/lib/Debug/libIlmBase_debug.a ../../../../External/lib/Debug/libtbb_debug.a ../../../../External/lib/Debug/libzlib_debug.a /opt/cuda/lib64/libcublas.so /opt/cuda/lib64/libcusparse.so -ldl -lgomp -lcudadevrt -lcudart_static -lrt -lpthread -ldl 
/usr/bin/ld: ../../lib/libdeViewerCore.so: undefined reference to `std::runtime_error::operator=(std::runtime_error&&)'

/home/jjcasmar/usr/local/bin/c++是 的符号链接。我使用 gcc 8.3.0/usr/bin/g++-8

编辑:评论中没有重复

C++ gcc ld 未定义引用

评论

0赞 aschepler 8/2/2019
如果您和两者都没有,以防万一由于某种原因在名称上存在差异怎么办?nmgreplibdeViewerCore.solibstdc++.so.6-C
0赞 jjcasmar 8/2/2019
编辑问题,按照您的建议添加输出。看起来有差异,但我不知道它们来自哪里。
0赞 aschepler 8/2/2019
它抱怨的符号是 ,两者是相同的。您能否确定构建系统用于尝试链接可执行文件的完整命令?_ZNSt13runtime_erroraSEOS_
0赞 jjcasmar 8/2/2019
使用 link 命令更新
1赞 L. F. 8/2/2019
什么是未定义的引用/未解析的外部符号错误以及如何修复它?

答: 暂无答案