program linking fails when using custom built gcc

前端 未结 2 1069
醉话见心
醉话见心 2020-12-11 16:44

I\'m running a fedora 21 distribution, in which the default gcc is 4.9. I have a custom built gcc/g++ 4.8 in /usr/local/gcc48 (for instance, cuda requires gcc =< 4.8, and

相关标签:
2条回答
  • 2020-12-11 17:18

    It would be helpful if you post the error message in English.

    It appears that the undefined symbol is __cxa_throw_bad_array_new_length. The functions __cxa... come from the C++ runtime library. G++ usually ships with it's own version of this library, called libsupc++. I would guess that the custom-built G++ can not find this library or is emitting a reference to a symbol which is not in the newer (4.9) libsupc++. Try compiling the libsupc++ source that ships with your custom version of G++ and directing the linker toward it. You may also need to do this for libstdc++.

    0 讨论(0)
  • 2020-12-11 17:32

    __cxa_throw_bad_array_new_length was added in GCC 4.9. That's what the @CXXABI_1.3.8 version suffix means. You can look up those version codes here: https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html

    This error means that you are trying to link an object file /usr/lib64/vtk/libvtkCommonDataModel.so.1 compiled by GCC 4.9 or later with libstdc++.so or libsupc++.so from GCC 4.8 or earlier. Either rebuild libvtkCommonDataModel.so with GCC 4.8, or link against the correct libstdc++.so.

    Edit: Actually, if you want to compile with a newer version of GCC but run with an older libstdc++.so, that can be done.

    1. Compile with -D_GLIBCXX_USE_CXX11_ABI=0 if you want to compile with GCC 5+ and run with libstdc++.so from older GCC. See https://bugzilla.mozilla.org/show_bug.cgi?id=1153109 and Using dual ABI in the libstdc++ manual.

    2. Link against stdc++compat.cpp containing back-compat hacks from Mozilla. You can also take a look at my modified version which doesn't depend on any Mozilla headers, but it's slightly out of date. In particular, this defines a stub __cxa_throw_bad_array_new_length.

    0 讨论(0)
提交回复
热议问题