0

I am trying to compile a program using CGAL and linked to Boost. When I run the linker:

g++ -Wl,-O1 -Wl,-rpath,/home/name/Qt/5.4/gcc_64 -Wl,-rpath,/home/name/Qt/5.4/gcc_64/lib -o meld main.o mainwindow.o test.o moc_mainwindow.o   -lCGAL -lgmp -lmpfr -lboost_system -L/home/name/Qt/5.4/gcc_64/lib -lQt5Widgets -lQt5Gui -lQt5Core -lGL -lpthread 

and get the error

main.o: In function `global constructors keyed to main.cpp':
main.cpp:(.text+0x3f): undefined reference to `boost::system::generic_category()'

What am I doing wrong? I saw a couple of answers to similar questions but none seem to work for me.

olamundo
  • 23,991
  • 34
  • 108
  • 149
  • Could be the order you're linking stuff in, try moving `-lboost_system` to the end of the library list. Or use [this](https://stackoverflow.com/q/5651869/241631) – Praetorian Jun 19 '15 at 18:31
  • What is the full path to `libboost_system.so` ? – donjuedo Jun 19 '15 at 18:46
  • @donjuedo /usr/local/lib/libboost_system.so – olamundo Jun 19 '15 at 22:35
  • What does `file /usr/local/lib/libboost_system.so` tell you? This is an area I really don't know, so please don't shoot me. :-) But I noticed your Qt libs seems to be 64 bit. I am wondering if the linker won't use 32 bit for a 64 bit build. It would make sense to have some sort of provision for backward compatibility. – donjuedo Jun 19 '15 at 22:51
  • @donjuedo Thanks, I appreciate the help (no intention on shooting you ;)! I get `symbolic link to libboost_system.so.1.58.0` and then running `file` on that linked file I get `ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, not stripped` – olamundo Jun 19 '15 at 23:01
  • I'd try Praetorian's suggestion -- I have seen that work before. If it still does not, I'd try forcing the search with another -L option, for your full path to the right library. I know, you should not need that, but it is a mystery. – donjuedo Jun 19 '15 at 23:09
  • Oh! I noticed pthread. This old SO question, http://stackoverflow.com/questions/13467072/c-boost-undefined-reference-to-boostsystemgeneric-category mentions using the boost_system-mt library instead. It's worth a shot. – donjuedo Jun 19 '15 at 23:13

0 Answers0