有没有可能不使用pthread来构建protobuf ?

Is it possible to build protobuf without pthread?

本文关键字:构建 protobuf pthread 有可能      更新时间:2023-10-16

需要在没有pthread的实时操作系统上使用协议缓冲区。我可以通过这种方式静态地链接protobuf

g++ -g -Wall example.pb.cc example.cc -o example -static -lprotobuf -lpthread

然而,没有pthread我得到链接错误。是否可以配置protobuf在没有pthread的情况下工作?

不完全是。查看此未解决的问题。

有人已经修补了一个旧的protobuf版本,不再依赖于pthreads,见这里-如果你真的需要它,你可以看看,可能转发端口。

还请注意,当使用protobuf时,您应该使用pkg_config来获得正确的编译器和链接器标志,例如

pkg-config --cflags protobuf         # compiler flags
pkg-config --libs protobuf           # linker flags