简体   繁体   中英

gcc 4.8 linker error during linking boost thread library

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 :(

您还需要在具有-lboost_thread -lboost_system之后添加-lboost_thread

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) 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM