Installing Protobuf Development Libraries in MinGW

风格不统一 提交于 2019-12-14 03:34:13

问题


I installed Protobuf in MinGW from the sources on github.

When I try to compile my C++ program I get errors:

CMakeFiles/nxcore_interface.dir/main.cpp.o:main.cpp:(.rdata$.refptr._ZN6google8protobuf8internal13empty_string_E[.refptr._ZN6google8protobuf8internal13empty_string_E]+0x0): undefined reference to `google::protobuf::internal::empty_string_'
collect2: error: ld returned 1 exit status

I found something that indicates the development libs are not present:

Program with protocol-buffers don't compile with MinGW-w64: "undefined reference to google::protobuf:: ..."

I have included the -lprotobuf compiler flag.

After some searching I determined I need to use libprotobuf-dev but I am having trouble locating it.

Does anyone know where to get it, or is something else wrong?


回答1:


You should compile your application with pkg-config.

g++ my_program.cpp `pkg-config --cflags --libs protobuf`

If you don't have pkg-config you should locate libraries path and set them with -L option. Eg:

g++ my_program.cpp -L/usr/local/protobuf/lib -lprotobuf


来源:https://stackoverflow.com/questions/31634818/installing-protobuf-development-libraries-in-mingw

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!