0

I have compiled boost library myself using g++4.8 compilation finished with success. Everything is located in ~/bin/boost. After compilation all files are located in /Users/$(USER)/bin/boost/stage/lib/

Below necessary make parts:

CC=g++-4.8
LD=g++-4.8

BOOST_LIB_PATH=/Users/$(USER)/bin/boost/stage/lib/
BOOST_HEADER_PATH=/Users/$(USER)/bin/boost/

LFLAGS=-L$(BOOST_LIB_PATH) -lboost_thread

release: $(OBJ)
        $(LD) $(OBJ) obj/main.o $(LFLAGS) -o $(RELEASE_NAME) 

Everything goes ok during compilation but the linking process fail. Basically all errors look the same:

ndefined symbols for architecture x86_64:
  "boost::system::system_category()", referenced from:
      __static_initialization_and_destruction_0(int, int)

I have already read : Attempting to use Boost.Filesystem however it doesn't seem to link? C++ / Boost: Undefined Symbols in example? and many others but still did not find solution.

I have no idea where is problem, i have change the order of linking, i try to link directly thread library but i still get same result. Problems occur during compilation of https://github.com/dbedla/snake-cpp11 under mac os x 10.8.4 (I have to modify makefile)

I will be grateful for any suggestion how to solve problem.

Sorry for my english :(

Community
  • 1
  • 1
user1883149
  • 9
  • 1
  • 4

2 Answers2

5

You also need to add -lboost_system after where you had -lboost_thread.

C. K. Young
  • 219,335
  • 46
  • 382
  • 435
0

Your problem is with the boost system category, so you need to link against that (libboost_system), too.

CC=g++-4.8
LD=g++-4.8

BOOST_LIB_PATH=/Users/$(USER)/bin/boost/stage/lib/
BOOST_HEADER_PATH=/Users/$(USER)/bin/boost/

LFLAGS=-L$(BOOST_LIB_PATH) -lboost_thread -lboost_system

release: $(OBJ)
        $(LD) $(OBJ) obj/main.o $(LFLAGS) -o $(RELEASE_NAME) 
László Papp
  • 51,870
  • 39
  • 111
  • 135