0

I have quite a complex build which involves many static and shared libraries being linked into an executable on Ubuntu 14.04 using G++ 4.8. The example is too complex to reproduce here, but it amounts to this:

I use functions from the boost filesystem library in my code, then archive that into a static library, call it my_lib.a.

I then link like this:

g++ -g -o Build/main -L Build/libs -Wl,--start-group ...lots of libraries here... \
    Build/libs/my_lib.a -lboost_filesystem -Wl,--end-group

When I run this, I get:

/usr/bin/ld: Build/my_lib.a(my_code.o): undefined reference to symbol '_ZN5boost10filesystem4pathdVERKS1_'
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libboost_filesystem.so: error adding symbols: DSO missing from command line

From what I can tell from Google, this means that I should add -lboost_filesystem to my link command-line - but it is already there! I understand that the order of libraries is usually also important, but I thought that surrounding the objects and libraries with -Wl,--start-group and -Wl,--end-group should make that irrelevant - and in any case, I think I've got the order right. So what's going on?

Tom
  • 7,269
  • 1
  • 42
  • 69
  • This could be related, http://stackoverflow.com/a/17988317/5781248 – J.J. Hakala Feb 02 '16 at 15:25
  • Thanks, I'll try some of those suggestions. – Tom Feb 02 '16 at 15:28
  • I've switched to boost 1.60.0, built from scratch using `--std=c++11` and it's made no difference to this error. – Tom Feb 10 '16 at 12:42
  • Possible duplicate of [Strange linking error: DSO missing from command line](https://stackoverflow.com/questions/19901934/strange-linking-error-dso-missing-from-command-line) – perror Jul 18 '17 at 16:40

0 Answers0