windows 构建和使用 Google Protocol Buffers
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8510782/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Building and using Google Protocol Buffers
提问by Ross Hays
I am currently working on a project, and I am trying to implement Protocol Buffers to work as a serialization format to store data on the local computer, and then be read back at a later time. Some of the features of protocol buffers seem perfect for this project so I was eager to test it out but I have run into some issues.
我目前正在做一个项目,我正在尝试实现 Protocol Buffers 以作为序列化格式在本地计算机上存储数据,然后在稍后读回。协议缓冲区的一些特性对于这个项目来说似乎是完美的,所以我很想测试它,但我遇到了一些问题。
So far though, I have not even been able to get far enough to test out Protocol Buffers. I downloaded the most recent zip file (version 2.4.1) to my windows machine. I read through the install.txt located in the root of the folder, but it was for Unix based systems. I then saw that it came with a vsprojects folder and read through the instructions listed there. Basically, all I was told to do was open up a solution, and then build the entire solution in either Debug or Release. I instantly received several errors about "config.h" not being found.
到目前为止,我什至还没有能够测试Protocol Buffers。我将最新的 zip 文件(版本 2.4.1)下载到我的 Windows 机器上。我通读了位于文件夹根目录下的 install.txt,但它适用于基于 Unix 的系统。然后我看到它带有一个 vsprojects 文件夹,并通读了那里列出的说明。基本上,我被告知要做的就是打开一个解决方案,然后在 Debug 或 Release 中构建整个解决方案。我立即收到了几个关于找不到“config.h”的错误。
I checked over the Unix instructions again and step one was...
我再次检查了 Unix 说明,第一步是......
cd' to the directory containing the package's source code and type './configure' to configure the package for your system. If you're using
csh' on an old version of System V, you might need to typesh ./configure' instead to prevent
csh' from trying to execute `configure' itself.Running `configure' takes awhile. While running, it prints some messages telling which features it is checking for.
cd' to the directory containing the package's source code and type './configure' to configure the package for your system. If you're using
csh' 在旧版本的 System V 上,您可能需要键入sh ./configure' instead to prevent
csh' 来尝试执行 `configure' 本身。运行 `configure' 需要一段时间。在运行时,它会打印一些消息,告诉它正在检查哪些功能。
So I booted into ubuntu, which I rarely use, and tried follow these instructions. The step listed above went fine and I was even able to get to the next step and 'make' the project, but then when the time came to use 'make install' I received the following errors:
因此,我启动了我很少使用的 ubuntu,并尝试按照这些说明进行操作。上面列出的步骤进行得很顺利,我什至能够进入下一步并“制作”项目,但是到了使用“制作安装”的时候,我收到了以下错误:
ross@ubuntu:~/Desktop/protobuf-2.4.1$ make install
Making install in .
make[1]: Entering directory `/home/ross/Desktop/protobuf-2.4.1'
make[2]: Entering directory `/home/ross/Desktop/protobuf-2.4.1'
make[2]: Nothing to be done for `install-exec-am'.
test -z "/usr/local/lib/pkgconfig" || /bin/mkdir -p "/usr/local/lib/pkgconfig"
/bin/mkdir: cannot create directory `/usr/local/lib/pkgconfig': Permission denied
make[2]: *** [install-pkgconfigDATA] Error 1
make[2]: Leaving directory `/home/ross/Desktop/protobuf-2.4.1'
make[1]: *** [install-am] Error 2
make[1]: Leaving directory `/home/ross/Desktop/protobuf-2.4.1'
make: *[install-recursive] Error 1
制作:*[安装递归] 错误 1
I primarily use windows for development, and the entire project I am working with now is being made in windows, so I am a little concerned. Has anybody had any luck building Protocol Buffers in either windows or linux?
我主要是用windows做开发,我现在做的整个项目都是windows做的,所以有点担心。有没有人在 windows 或 linux 中构建协议缓冲区有任何运气?
Thank you
谢谢
回答by favoretti
You can't do make install
as your own user, when you're trying to install it system-wide.
Either use sudo make install
if you have sudo rights, or become root any other possible way and then run it.
make install
当您尝试在系统范围内安装它时,您不能以自己的用户身份进行操作。sudo make install
如果您有 sudo 权限,请使用,或者以任何其他可能的方式成为 root,然后运行它。
If you don't have admin rights, you can run ./configure --prefix=$HOME/protobuffers
, compile and run make install
again, it will install them in your home dir in subdir called protobuffers
. Note that you might want to adjust your LD_LIBRARY_PATH
in profile after that to be able to find libraries. If you only need protoc
, that should do the trick.
如果您没有管理员权限,您可以运行./configure --prefix=$HOME/protobuffers
、编译并make install
再次运行,它会将它们安装在您的主目录中名为protobuffers
. 请注意,您可能希望LD_LIBRARY_PATH
在此之后调整您的个人资料以便能够找到库。如果您只需要protoc
,那应该可以解决问题。
--- edit ---
- - 编辑 - -
Speaking of which, protoc is also available for windows, and you can use them there as well. You can download it here.
说到这里,protoc 也适用于 windows,你也可以在那里使用它们。你可以在这里下载。