Search code examples
c++linuxgcclinkershared-libraries

gcc10 wants an extra .so file that gcc8 does not need for linking


Im compiling my C++ code with an gcc10 and the linker wants an libspeckle.so file that i do not have. However compiling the same programm with gcc8 or gcc9 and the same compiler and linker flags, it does not need the libspeckle.so file for linking and it works just fine.

For a beginner like me that is very confusing because i cant execute/link my programm with any modern compiler, i tried gcc10, gcc11, clang13, clang14, clang15, but nothing worked besides the gcc8 and gcc9 compiler.

For linkers i also tried out ld, gold, ldd and mold, no difference.

I tried using the -Wl,--unresolved-symbols=ignore-in-shared-libs linker flag, but then i can't execute my programm.

Could someone help me understand this.

"generator": "Ninja Multi-Config",
"environment": {
    "COMPILER": "gcc11",
    "cmakeBuildOptions": "-- -v",
    "CC": "gcc-11",
    "CXX": "g++-11",
    "ARCHITECTURE": "x64",
    "LDFLAGS": "-g",
    "CFLAGS": "-fsanitize=address -fprofile-arcs -ftest-coverage -m64 -g -Wall -Wextra -pedantic -fPIC",
    "CXXFLAGS": "-fsanitize=address -fprofile-arcs -ftest-coverage -m64 -g -Wall -Wextra -pedantic -fPIC"
}

ldd from executable compiled with gcc8 =>

ldd ./UnitTest | grep -i libspeckle
       

ldd from executable compiled with gcc11 =>

ldd ./UnitTest | grep -i libspeckle
        libspeckle.so.1 => not found                                                                                                                             

Solution

  • You can use the -fobjc-gc flag in order to fix this. This should solve the problem.

    You can check the flags here