在MinGW中安装Protobuf开发库 [英] Installing Protobuf Development Libraries in MinGW
问题描述
我从github上的源代码在MinGW中安装了Protobuf.
I installed Protobuf in MinGW from the sources on github.
当我尝试编译C ++程序时,出现错误:
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:
带有协议缓冲区的程序不要t使用MinGW-w64进行编译:对google :: protobuf :: ...的未定义引用"
我已经包含了-lprotobuf
编译器标志.
I have included the -lprotobuf
compiler flag.
经过一番搜索,我确定需要使用libprotobuf-dev
,但是找不到它.
After some searching I determined I need to use libprotobuf-dev
but I am having trouble locating it.
有人知道从哪里获得它,还是有其他问题?
推荐答案
您应使用pkg-config编译应用程序.
You should compile your application with pkg-config.
g++ my_program.cpp `pkg-config --cflags --libs protobuf`
如果没有pkg-config,则应找到库路径并使用-L选项进行设置.例如:
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
这篇关于在MinGW中安装Protobuf开发库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!