Closed liver0377 closed 1 year ago
您好,已收到您的来信,谢谢!
可能是版本兼容性问题,你可以安装 portobuf 3.19.4 版本试试,这个版本用c++11就能编译。你可能安装的是最新的 protobuf,需要用c++14编译。
安装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
将之前的编译产物删除后, 重新编译通过了
第一次
make
时protobuf显式至少C++版本至少是C++14, 手动修改makefile的编译选项为-std=c++14之后有如下链接问题protobuf
版本