我刚刚安装了Boost 1_55库,它位于: /主机/用户/ Szymon /下载/ boost_1_55_0 /升压/ 这是我的Makefile:
#Source file
SRC = example01.cpp
#Object file
OBJ = $(SRC:.cpp=.o)
#Output execution file
PROGRAM = example01
PROGRAM_EXT =
#Compiler
CC = g++
#Boost
BOOST = /host/Users/Szymon/Downloads/boost_1_55_0
#BOOST = /usr/include/boost
#Include
INCLUDE = -I/usr/include/ -I$(BOOST)/include
#Linker Parameter
LINKPARAM = -L$(BOOST)/lib -lboost_thread -lboost_system
#Options for development
CFLAGS = -g -Wall -Wextra -std=c++0x
all: $(PROGRAM).$(PROGRAM_EXT)
$(PROGRAM).$(PROGRAM_EXT): $(OBJ)
$(CC) -o $(PROGRAM) $(LINKPARAM) $(OBJ)
.SUFFIXES = .cpp
.cpp.o:
$(CC) $(INCLUDE) $(CFLAGS) -c $<
clean:
rm *.o
rm example01
但是当我编写代码时,我收到了错误:
g++ -o example01 -L/host/Users/Szymon/Downloads/boost_1_55_0/lib -lboost_thread -lboost_system example01.o
example01.o: In function `__static_initialization_and_destruction_0':
/usr/include/boost/system/error_code.hpp:214: undefined reference to `boost::system::generic_category()'
/usr/include/boost/system/error_code.hpp:215: undefined reference to `boost::system::generic_category()'
/usr/include/boost/system/error_code.hpp:216: undefined reference to `boost::system::system_category()'
example01.o: In function `error_code':
/usr/include/boost/system/error_code.hpp:315: undefined reference to `boost::system::system_category()'
example01.o: In function `boost::asio::error::get_system_category()':
/usr/include/boost/asio/error.hpp:220: undefined reference to `boost::system::system_category()'
example01.o: In function `boost::asio::detail::posix_tss_ptr_create(unsigned int&)':
/usr/include/boost/asio/detail/impl/posix_tss_ptr.ipp:34: undefined reference to `pthread_key_create'
example01.o: In function `~posix_tss_ptr':
/usr/include/boost/asio/detail/posix_tss_ptr.hpp:48: undefined reference to `pthread_key_delete'
/usr/include/boost/asio/detail/posix_tss_ptr.hpp:48: undefined reference to `pthread_key_delete'
collect2: ld returned 1 exit status
make: *** [example01.] Error 1
我很确定我的Makefile有问题,有人可以帮忙吗?我使用apt-get安装了Boost。 提前谢谢,