链接 protobuf 就崩溃

发布时间 2023-10-03 09:17:53作者: SupperMary

跟着官网的Demo试验了一下,发现跑起来就Abort了,下面是具体的报错

terminate called after throwing an instance of 'std::system_error'
  what():  Unknown error -1
Aborted (core dumped)

通过不停的删减代码和修改编译命令,定位到链接了 protobuf 就会崩溃。
GitHub 搜索到了相应的信息,链接 protobuf 和 pthread 即可,例如

g++ sample.cc example.pb.cc -lprotobuf -pthread