将protobuf库与代码链接(Google协议缓冲区) [英] Linking protobuf library with code (Google protocol buffers)

查看:325
本文介绍了将protobuf库与代码链接(Google协议缓冲区)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试编译测试代码时出现链接错误. 我在Windows 7上使用cygwin. 初始步骤如./configure、make、make test&使安装正常

I am getting linking error when I try to compile a test code. I'm using cygwin on windows 7. Initial steps like ./configure, make, make test & make install went fine

我还可以使用protoc命令生成.pb.cc和.pb.h.

I'm also able to generate .pb.cc and .pb.h with protoc command.

但是当我尝试编译测试代码时,它会遇到许多链接错误.我确定这些错误是因为它无法链接到库.

But when I try to compile my test code, it gets many linking errors. I'm sure those errors are because it is unable to link to library.

Cygwin在/usr/local/lib中具有protobuf静态库和链接库 .包含文件位于/usr/local/include

Cygwin has protobuf static library and linking library in /usr/local/lib . include files are present in /usr/local/include

我尝试使用-lprotobuf,但返回错误,提示-lprotobuf未找到

I tried with -lprotobuf, but it returns error saying -lprotobuf not found

推荐答案

很难说问题出在哪里,因为您既不包含makefile,也不包含错误,但是我猜测是路径/usr/local/lib并不存在查找库时包含在搜索路径中.

It hard to say what the problem is since you don't include neither the makefile nor the errors, but my guess is that the path /usr/local/lib is not included in the search path when looking for libraries.

尝试在-lprotobuf之前添加-L/usr/local/lib.

这篇关于将protobuf库与代码链接(Google协议缓冲区)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆