如何更改makefile,而是编译.so而不是.a?

时间:2019-07-16 14:20:10

标签: c++ linux dll makefile .so

我想将pslite(https://github.com/dmlc/ps-lite)编译为.so而不是.a,并且makefile是(https://github.com/dmlc/ps-lite/blob/master/Makefile)。

我遇到错误:

/root/hbsun/hbsun_Athena/pssrc/van.cc:464: undefined reference to `google::protobuf::MessageLite::ParseFromArray(void const*, int)'
build/van.o: In function `google::protobuf::RepeatedField<int>::Get(int) const':
/home/xiaonan/hbsun/hbsun_Athena/deps/include/google/protobuf/repeated_field.h:1182: undefined reference to `google::protobuf::internal::LogMessage::LogMessage(google::protobuf::LogLevel, char const*, int)'
/home/xiaonan/hbsun/hbsun_Athena/deps/include/google/protobuf/repeated_field.h:1182: undefined reference to `google::protobuf::internal::LogMessage::operator<<(char const*)'
/home/xiaonan/hbsun/hbsun_Athena/deps/include/google/protobuf/repeated_field.h:1182: undefined reference to `google::protobuf::internal::LogFinisher::operator=(google::protobuf::internal::LogMessage&)'
/home/xiaonan/hbsun/hbsun_Athena/deps/include/google/protobuf/repeated_field.h:1182: undefined reference to `google::protobuf::internal::LogMessage::~LogMessage()'
/home/xiaonan/hbsun/hbsun_Athena/deps/include/google/protobuf/repeated_field.h:1181: undefined reference to `google::protobuf::internal::LogMessage::LogMessage(google::protobuf::LogLevel, char const*, int)'
/home/xiaonan/hbsun/hbsun_Athena/deps/include/google/protobuf/repeated_field.h:1181: undefined reference to `google::protobuf::internal::LogMessage::operator<<(char const*)'
/home/xiaonan/hbsun/hbsun_Athena/deps/include/google/protobuf/repeated_field.h:1181: undefined reference to `google::protobuf::internal::LogFinisher::operator=(google::protobuf::internal::LogMessage&)'
/home/xiaonan/hbsun/hbsun_Athena/deps/include/google/protobuf/repeated_field.h:1181: undefined reference to `google::protobuf::internal::LogMessage::~LogMessage()'

1 个答案:

答案 0 :(得分:0)

您提到的makefile用于构建静态库,首先更改构建命令:

来自

build/libps.a: $(OBJS)
    ar crv $@ $(filter %.o, $?)

build/libps.so: $(OBJS)
    gcc -fPIC -shared $@ $(filter %.o, $?)