编译链接 protobuf时出现的错误

问题描述

1.编译protobuf的时候会出现链接错误:

undefined reference to `google::protobuf::Message::SpaceUsedLong() const'

 

2.编译的时候会出现

terminate called after throwing an instance of 'google::protobuf::FatalException'
  what():  CHECK failed: (scc->visit_status.load(std::memory_order_relaxed)) == (SCCInfoBase::kRunning):
Aborted (core dumped)

 

解决方法

1.链接到protobuf静态库即可:

g++ -lprotobuf

 

2.初次编译可能会出现这个问题,需要添加

g++ -lpthread

 

后面编译就不会出现这个问题,不加pthread也可以编译通过。

环境

centos 7
libprotoc 3.14.0

posted @ 2021-01-21 15:33  LiuYanYGZ  阅读(3221)  评论(0编辑  收藏  举报