makefile文件的编写问题
工程文件目录:
barrage.pb.cc ClientProtoHelper.cpp md5.o
barrage.pb.h ClientProtoHelper.h mid_net_socket_tcp.cpp
barrage.pb.o ClientProtoHelper.o libprotobuf.a mid_net_socket_tcp.h
buffer.cpp crc32.cpp makefile mid_net_socket_tcp.o
buffer.h crc32.h md5.cpp ssmain.cpp
buffer.o crc32.o md5.h ssmain.o
我的makefile文件:
SERVERDIR=.
PROTOBUF=./
CRYPTO=./cryptopp
CC=g++
CXX=g++
INC2=-I$(SERVERDIR)/ -I$(PROTOBUF) -I$(CRYPTO)
LIB=./libprotobuf.a ./cryptopp/libcryptopp.a
CFLAGS= -Wall -g
TARGET=gate_test
OBJ+=ssmain.o \
./ClientProtoHelper.o \
buffer.o \
md5.o\
mid_net_socket_tcp.o \
barrage.pb.o \
crc32.o
$(TARGET):$(OBJ)
$(CXX) $(CFLAGS) -o $@ $^ $(LIB)
%.o: %.cpp
$(CXX) $(CFLAGS) $(INC2) -c -o $@ $<
%.o: %.c
$(CXX) $(CFLAGS) $(INC2) -c -o $@ $<
%.o: %.cc
$(CXX) $(CFLAGS) $(INC2) -c -o $@ $<
clean:
rm -f $(OBJ)
rm -f $(TARGET)
问题:为何会报这种未定义的错误呢
ssmain.o:在函数‘google::protobuf::internal::GetEmptyStringAlreadyInited[abi:cxx11]()’中:
/root/barrage/barrage/./google/protobuf/generated_message_util.h:80:对‘google::protobuf::internal::empty_string_[abi:cxx11]’未定义的引用
/root/barrage/barrage/./google/protobuf/generated_message_util.h:81:对‘google::protobuf::internal::empty_string_[abi:cxx11]’未定义的引用
ClientProtoHelper.o:在函数‘CClientProtolHelper::TcpSendRecv(unsigned int, unsigned short, SSendContextInfo const&, google::protobuf::Message const&, google::protobuf::Message&)’中:
/root/barrage/barrage/ClientProtoHelper.cpp:83:对‘google::protobuf::MessageLite::SerializeToString(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*) const’未定义的引用