繁体   English   中英

使用协议缓冲区的程序无法用MinGW-w64编译:“对google :: protobuf ::…的未定义引用”

[英]Program with protocol-buffers don't compile with MinGW-w64: “undefined reference to google::protobuf:: …”

我已经从Debian Jessie信息库安装了libprotobuf-dev=2.6.0-4protobuf-compiler=2.6.0-4软件包。 现在,我正在尝试使用MinGW-w64编译器编译使用Google Developers 示例中的“ addressbook.proto”文件的程序。 我正在使用Ubuntu 14.04。

使用此命令,程序可以工作:

$ g++ main.cpp addressbook.pb.cc -lprotobuf

但是我也想为Windows编译。

我添加了符号链接: /usr/include/google > /usr/i686-w64-mingw32/include/google

$ i686-w64-mingw32-g++ main.cpp addressbook.pb.cc -lprotobuf
/usr/bin/i686-w64-mingw32-ld: cannot find -lprotobuf
collect2: error: ld returned 1 exit status

在库位置仍然无法使用的情况下:

$ i686-w64-mingw32-g++ -L /usr/lib/i386-linux-gnu/ main.cpp addressbook.pb.cc -lprotobuf
/tmp/ccB1VJyR.o:main.cpp:(.text$_ZN6google8protobuf8internal27GetEmptyStringAlreadyInitedEv[__ZN6google8protobuf8internal27GetEmptyStringAlreadyInitedEv]+0x7): undefined reference to `google::protobuf::internal::empty_string_'
/tmp/ccB1VJyR.o:main.cpp:(.text$_ZN6google8protobuf8internal27GetEmptyStringAlreadyInitedEv[__ZN6google8protobuf8internal27GetEmptyStringAlreadyInitedEv]+0x2f): undefined reference to `google::protobuf::internal::empty_string_'
/tmp/ccPz4uiI.o:addressbook.pb.cc:(.text+0x78): undefined reference to `google::protobuf::DescriptorPool::generated_pool()'
/tmp/ccPz4uiI.o:addressbook.pb.cc:(.text+0x87): undefined reference to `google::protobuf::DescriptorPool::FindFileByName(std::string const&) const'
...

libprotobuf-dev包含系统的库头和预构建的二进制文件。 如果要交叉编译,则还需要将库从源代码编译到目标系统。 库源目录中的“ ./configure CC = i686-w64-mingw32-g ++”之类的东西应该可以完成此工作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM