Reputation: 26742
I am attempting to build and link a library with Clang instead of the default GCC and I am getting the following linker error:
/usr/bin/ld: build/temp.linux-x86_64-3.6/torch/csrc/autograd/engine.o: undefined reference to symbol '_ZNSt18condition_variable10notify_oneEv@@GLIBCXX_3.4.11'
My command is:
CC="clang-5.0" CXX="clang++-5.0" LDSHARED="clang -shared" python setup.py install
Removing LDSHARED
solves the problem but I need to link with clang
, because in the full example CFLAGS
contains flags that GCC does not recognize.
Upvotes: 3
Views: 6059
Reputation: 26742
Clang is linking by default against libc++
(https://libcxx.llvm.org/docs/UsingLibcxx.html) rather than libstdc++
, which the code seems to be built against. Adding LDFLAGS="-stdlib=libstdc++"
solves the problem.
Upvotes: 2