Gooddbird / tinyrpc

c++ async rpc framework. 14w+qps.
Apache License 2.0
1.26k stars 189 forks source link

编译时 protobuf 链接出错 #55

Closed liver0377 closed 1 year ago

liver0377 commented 1 year ago

第一次make时protobuf显式至少C++版本至少是C++14, 手动修改makefile的编译选项为-std=c++14之后有如下链接问题

/usr/bin/ld: extension_set.cc:(.text+0x906e): undefined reference to `absl::lts_20230125::log_internal::LogMessageFatal::~LogMessageFatal()'
/usr/bin/ld: /usr/local/lib/libprotobuf.a(extension_set.cc.o): in function `google::protobuf::internal::ExtensionSet::SetRepeatedEnum(int, int, int)':
extension_set.cc:(.text+0x910e): undefined reference to `absl::lts_20230125::log_internal::LogMessageFatal::LogMessageFatal(char const*, int, std::basic_string_view<char, std::char_traits<char> >)'
/usr/bin/ld: extension_set.cc:(.text+0x9150): undefined reference to `absl::lts_20230125::log_internal::LogMessageFatal::~LogMessageFatal()'
/usr/bin/ld: extension_set.cc:(.text+0x91d7): undefined reference to `absl::lts_20230125::log_internal::LogMessageFatal::LogMessageFatal(char const*, int, std::basic_string_view<char, std::char_traits<char> >)'
/usr/bin/ld: extension_set.cc:(.text+0x91ef): undefined reference to `absl::lts_20230125::log_internal::LogMessageFatal::~LogMessageFatal()'
/usr/bin/ld: extension_set.cc:(.text+0x9270): undefined reference to `absl::lts_20230125::log_internal::LogMessageFatal::LogMessageFatal(char const*, int, std::basic_string_view<char, std::char_traits<char> >)'
/usr/bin/ld: extension_set.cc:(.text+0x9288): undefined reference to `absl::lts_20230125::log_internal::LogMessageFatal::~LogMessageFatal()'
/usr/bin/ld: extension_set.cc:(.text+0x92c6): undefined reference to `absl::lts_20230125::log_internal::LogMessageFatal::~LogMessageFatal()

protobuf版本 image

AIGC-yuxincai commented 1 year ago

您好,已收到您的来信,谢谢!

Gooddbird commented 1 year ago

可能是版本兼容性问题,你可以安装 portobuf 3.19.4 版本试试,这个版本用c++11就能编译。你可能安装的是最新的 protobuf,需要用c++14编译。

liver0377 commented 1 year ago

安装protobuf 3.19.4之后make报错

g++ -g -O0 -std=c++11 -Wall -Wno-deprecated -Wno-unused-but-set-variable -I./ -Itinyrpc -Itinyrpc/comm -Itinyrpc/coroutine -Itinyrpc/net -Itinyrpc/net/http -Itinyrpc/net/tcp -Itinyrpc/net/tinypb testcases/test_tinypb_server.cc testcases/test_tinypb_server.pb.cc -o bin/test_tinypb_server lib/libtinyrpc.a /usr/local/lib/libprotobuf.a     /usr/lib/libtinyxml.a -ldl -pthread 
/usr/bin/ld: lib/libtinyrpc.a(tinypb_rpc_dispatcher.o): in function `tinyrpc::TinyPbRpcDispacther::dispatch(tinyrpc::AbstractData*, tinyrpc::TcpConnection*)':
/home/ubuntu/Project/tinyrpc/tinyrpc/net/tinypb/tinypb_rpc_dispatcher.cc:70: undefined reference to `google::protobuf::ServiceDescriptor::FindMethodByName(absl::lts_20230125::string_view) const'
/usr/bin/ld: /home/ubuntu/Project/tinyrpc/tinyrpc/net/tinypb/tinypb_rpc_dispatcher.cc:84: undefined reference to `google::protobuf::MessageLite::ParseFromString(absl::lts_20230125::string_view)'
collect2: error: ld returned 1 exit status
make: *** [makefile:70: bin/test_tinypb_server] Error 1
liver0377 commented 1 year ago

将之前的编译产物删除后, 重新编译通过了