2

I'm having an issue trying to link a project. Its giving me the following output

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

deSimViewer is a target configured with cmake and it only links against deViewerCore.

Doing ldd deViewerCore.so I get the following output (cropped to show only the interesting part)

        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)

so it's linked against libstdc++.so.6.

nm -C /usr/lib/libstdc++.so.6 | grep runtime_error shows the operator= exists

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

so I have no clue what it's going on and why it's not linking.

Any idea of what might be happening?

EDIT: Add output of nm without demangling as suggested in the comments

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

looks like there is a difference in the some names: @@GLIBCXX_3.4

EDIT: Show the full linker command

/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++ is a symlink to /usr/bin/g++-8. Im using gcc 8.3.0

Edit: No duplicate as said on the comments

jjcasmar
  • 1,387
  • 1
  • 18
  • 30
  • What if you `nm` and `grep` both `libdeViewerCore.so` and `libstdc++.so.6` without the `-C`, just in case there's a difference in name mangling for some reason? – aschepler Aug 02 '19 at 04:52
  • edited the question adding the output as you suggested. It looks there are differences, but I have no clue where they come from. – jjcasmar Aug 02 '19 at 05:02
  • The symbol it's complaining about is `_ZNSt13runtime_erroraSEOS_`, which is the same in both. Can you determine the full command the build system is using to attempt to link the executable? – aschepler Aug 02 '19 at 05:08
  • updated with the link command – jjcasmar Aug 02 '19 at 05:17
  • 1
    Possible duplicate of [What is an undefined reference/unresolved external symbol error and how do I fix it?](https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – L. F. Aug 02 '19 at 05:21
  • @L.F. The question shows an understanding of what an undefined symbol reference means, and this doesn't appear to be a case of any of the frequent mistakes listed in the answers there. – aschepler Aug 02 '19 at 05:27
  • @aschepler any other idea after posting the linker command? thanks! – jjcasmar Aug 02 '19 at 06:12
  • Sorry, I don't understand this one. It's a little suspicious the symbol looks like the only standard library symbol (after grep) in libdeViewerCore.so without a `@@GLIBCXX` version, but I'm not very familiar with how those symbol versions work. – aschepler Aug 02 '19 at 14:08
  • Oh, one idea: I think gcc might sometimes decide whether to link in C mode or C++ mode based on its own `argv[0]`. Any difference if you manually try the link command but replacing `c++` with `/usr/bin/g++-8`? – aschepler Aug 02 '19 at 14:15
  • So I tried what you said. With `/usr/bin/g++-8` it didnt work, but with `/usr/bin/g++` (which is gcc 9) works fine. Strange, since trying to compile/link everything with `/usr/bin/g++` gives me a bunch of `std::__cxx11::string` link errors... – jjcasmar Aug 02 '19 at 14:35

0 Answers0