7

I'm trying to link with boost, using clang under ubuntu. And I get following error:

/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libboost_filesystem.a(operations.o): undefined reference to symbol '_ZNSs4_Rep10_M_destroyERKSaIcE@@GLIBCXX_3.4'
/usr/lib/x86_64-linux-gnu/libstdc++.so.6: error adding symbols: DSO missing from command line
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I've added find_package(Boost COMPONENTS file_system, system) to cmake. Any idea what may cause this error?

Michał Dębski
  • 527
  • 4
  • 16

1 Answers1

9

This error was because Boost was build using gcc standard library libstdc++ and I was compiling using clang libc++.

Previously I was using Boost downloaded with apt-get. Downloading sources from boost.org and compiling by hand using clang and its standard library fixed this problem.

Michał Dębski
  • 527
  • 4
  • 16
  • 1
    I got a similar message, when switching from `g++` to `clang++` I accidentally typed `clang` instead (C-only/automatic compiler, which means among other things that it didn't like correctly to `libc++`). – alfC May 10 '17 at 04:54