4
當我嘗試使用boost來編譯我的服務器時,出現很多錯誤。 這裏,這是我的makefile:當我嘗試編譯時遇到boost的未定義引用
NAME = serveur
SRCS = Serveur/main.cpp \
Serveur/Client.cpp \
Serveur/Commande.cpp \
Serveur/My_exception.cpp \
Serveur/Network.cpp \
Serveur/Server.cpp
#####################################################
OBJS = $(SRCS:.cpp=.o)
CC = g++
RM = rm -f
CFLAGS = -g -W -Wall -Werror
INCL = ./Serveur/boost_1_47_0
LIB = ./Serveur/boost_1_47_0/stage/lib/
NLIB = -lboost_system -lboost_system-mt -lboost_filesystem -lboost_filesystem-mt
#####################################################
$(NAME) : $(OBJS)
@$(CC) $(OBJS) -I$(INCL) -L$(LIB) $(NLIB) -o $(NAME)
@printf "\n \033[33m[Message]\033[39m Compilation under Linux done\n\n"
.cpp.o :
@$(CC) $(CFLAGS) -I$(INCL) -L$(LIB) $(NLIB) -c $< -o [email protected]
@printf " \033[34m[Compilation]\033[39m %s\n" $<
re : fclean all
all : $(NAME)
clean :
@$(RM) *~ $(OBJS)
@printf " \033[31m[Delete] \033[39m%s\n" $(OBJS)
fclean : clean
@$(RM) $(NAME)
@printf "\n \033[31m[Delete] \033[39m%s\n\n" $(NAME)
「google搜索」我發現,有必要把-lboost_filesystem
後,但它沒有再工作,旁邊還有錯誤:
Serveur/main.o: In function `__static_initialization_and_destruction_0':
/home/abad_a//rendulocal/tech3/cpp/babel-2014-abad_a/Serveur/./Serveur/boost_1_47_0/boost/system/error_code.hpp:214: undefined reference to `boost::system::generic_category()'
/home/abad_a//rendulocal/tech3/cpp/babel-2014-abad_a/Serveur/./Serveur/boost_1_47_0/boost/system/error_code.hpp:215: undefined reference to `boost::system::generic_category()'
/home/abad_a//rendulocal/tech3/cpp/babel-2014-abad_a/Serveur/./Serveur/boost_1_47_0/boost/system/error_code.hpp:216: undefined reference to `boost::system::system_category()'
Serveur/main.o: In function `error_code':
/home/abad_a//rendulocal/tech3/cpp/babel-2014-abad_a/Serveur/./Serveur/boost_1_47_0/boost/system/error_code.hpp:315: undefined reference to `boost::system::system_category()'
Serveur/main.o: In function `boost::asio::error::get_system_category()':
/home/abad_a//rendulocal/tech3/cpp/babel-2014-abad_a/Serveur/./Serveur/boost_1_47_0/boost/asio/error.hpp:216: undefined reference to `boost::system::system_category()'
Serveur/Client.o: In function `__static_initialization_and_destruction_0':
/home/abad_a//rendulocal/tech3/cpp/babel-2014-abad_a/Serveur/./Serveur/boost_1_47_0/boost/system/error_code.hpp:214: undefined reference to `boost::system::generic_category()'
/home/abad_a//rendulocal/tech3/cpp/babel-2014-abad_a/Serveur/./Serveur/boost_1_47_0/boost/system/error_code.hpp:215: undefined reference to `boost::system::generic_category()'
/home/abad_a//rendulocal/tech3/cpp/babel-2014-abad_a/Serveur/./Serveur/boost_1_47_0/boost/system/error_code.hpp:216: undefined reference to `boost::system::system_category()'
Serveur/Network.o: In function `__static_initialization_and_destruction_0':
/home/abad_a//rendulocal/tech3/cpp/babel-2014-abad_a/Serveur/./Serveur/boost_1_47_0/boost/system/error_code.hpp:214: undefined reference to `boost::system::generic_category()'
/home/abad_a//rendulocal/tech3/cpp/babel-2014-abad_a/Serveur/./Serveur/boost_1_47_0/boost/system/error_code.hpp:215: undefined reference to `boost::system::generic_category()'
/home/abad_a//rendulocal/tech3/cpp/babel-2014-abad_a/Serveur/./Serveur/boost_1_47_0/boost/system/error_code.hpp:216: undefined reference to `boost::system::system_category()'
Serveur/Server.o: In function `__static_initialization_and_destruction_0':
/home/abad_a//rendulocal/tech3/cpp/babel-2014-abad_a/Serveur/./Serveur/boost_1_47_0/boost/system/error_code.hpp:214: undefined reference to `boost::system::generic_category()'
/home/abad_a//rendulocal/tech3/cpp/babel-2014-abad_a/Serveur/./Serveur/boost_1_47_0/boost/system/error_code.hpp:215: undefined reference to `boost::system::generic_category()'
/home/abad_a//rendulocal/tech3/cpp/babel-2014-abad_a/Serveur/./Serveur/boost_1_47_0/boost/system/error_code.hpp:216: undefined reference to `boost::system::system_category()'
collect2: ld returned 1 exit status
make: *** [serveur] Error 1
任何人都知道它爲什麼不加工?
這是同樣的結果:( –
你還在首先,在你的'INCL'變量中你有'Serveur'這個目錄,但是在你的'LIB'變量中,你有'boost :: system'錯誤嗎? – rcollyer
是的,它們是相同的錯誤 –