C++ Linux 中的 Google protobuf
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2456664/
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
Google protobuf in Linux
提问by Max Frai
I'm working with protobuf and Linux. Where is its compiler protoc
. I've downloaded package from main site, compiled and installed it successfully but I can't find protoc
to build my own format file. Where is it?
我正在使用 protobuf 和 Linux。它的编译器在哪里protoc
。我已经从主站点下载了软件包,编译并成功安装了它,但我找不到protoc
构建自己的格式文件。它在哪里?
UPDATEHere is folder where I built protobuf:
更新这是我构建 protobuf 的文件夹:
aclocal.m4 depcomp Makefile.in
autogen.sh editors missing
CHANGES.txt examples protobuf-lite.pc
config.guess generate_descriptor_proto.sh protobuf-lite.pc.in
config.h gtest protobuf.pc
config.h.in install-sh protobuf.pc.in
config.log INSTALL.txt python
config.status java README.txt
config.sub libtool src
configure ltmain.sh stamp-h1
configure.ac m4 vsprojects
CONTRIBUTORS.txt Makefile
COPYING.txt Makefile.am
There isn't binary file I need.
没有我需要的二进制文件。
回答by daveb
It's probably installed into /usr/local/bin
它可能已安装到 /usr/local/bin
On Ubuntu at least, you can apt-get install protobuf-compiler
instead.
至少在 Ubuntu 上,你可以apt-get install protobuf-compiler
代替。
From the INSTALL.txt:
从 INSTALL.txt:
Installation Names
By default, 'make install' will install the package's files in '/usr/local/bin', '/usr/local/man', etc. You can specify an installation prefix other than '/usr/local' by giving 'configure' the option '--prefix=PATH'.
安装名称
默认情况下,'make install' 会在 '/usr/local/bin'、'/usr/local/man' 等目录中安装包的文件。你可以通过给出 '配置'选项'--prefix = PATH'。
回答by Dirk Eddelbuettel
Also, if you are in fact on Ubuntu, then you can also fetch the source package from Debian unstable and rebuild them locally if you want packages that are more current than the last cutoff (which for Ubuntu 9.10 was some time late last summer). That way you end up with .deb packages and you preserve a normal upgrade path (rather than littering /usr/local with one-off installs).
此外,如果您实际上使用的是 Ubuntu,那么如果您想要比上次截止日期(对于 Ubuntu 9.10 是去年夏末的某个时间)更新的软件包,您还可以从 Debian 不稳定版获取源代码包并在本地重建它们。这样,您最终会得到 .deb 包并保留正常的升级路径(而不是一次性安装乱扔垃圾 /usr/local)。
回答by MYLOGOS
First, you need to compile you source code from protobuff (in the root folder):
首先,您需要从 protobuff(在根文件夹中)编译源代码:
./configure
make
make check
make install
Second:
第二:
echo "/usr/local/lib">>/etc/ld.so.conf
echo "/usr/lib">>/etc/ld.so.conf
ldconfig
Third:
第三:
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH
Read README.txt in root folder for more info.
阅读根文件夹中的 README.txt 以获取更多信息。
回答by Abdelrahman Yosry
Actually you don't need to know it's place. All you want is to open terminal where your proto file is located and write at terminal
其实你不需要知道它的位置。您只需要打开 proto 文件所在的终端并在终端写入
protoc -I=. --cpp_out=. filename.proto
follow this link for documentation
按照此链接获取文档
回答by Milo
You can find protoc in the path which you set ./configure --prefix=you_path. When you make install successful, it will general bin, include and lib in that path.
您可以在您设置的路径中找到 protoc ./configure --prefix=you_path。当您安装成功时,它将在该路径中通用 bin、include 和 lib。