Google protobuf use for Linux

25 篇文章 0 订阅

1.  Download the protobuf file , for example version is , protobuf-2.4.1

2. Unzip in linux

3. Open the README.txt , we can see the make file.

4.  look through the file. and follow the indication.

C++ Installation - Unix
=======================

To build and install the C++ Protocol Buffer runtime and the Protocol
Buffer compiler (protoc) execute the following:

  $ ./configure
  $ make
  $ make check
  $ make install

If "make check" fails, you can still install, but it is likely that
some features of this library will not work correctly on your system.
Proceed at your own risk.

"make install" may require superuser privileges.

For advanced usage information on configure and make, see INSTALL.txt.

5. Install location

** Hint on install location **

  By default, the package will be installed to /usr/local.  However,
  on many platforms, /usr/local/lib is not part of LD_LIBRARY_PATH.
  You can add it, but it may be easier to just install to /usr
  instead.  To do this, invoke configure as follows:

    ./configure --prefix=/usr

  If you already built the package with a different prefix, make sure
  to run "make clean" before building again.

 

6. In the proto***.proto directory, run the compile command

protoc -I=. --cpp_out=. Proto****.proto

*******************if filed ,try to do ******************

ldconfig

or

export LD_LIBRARY_PATH=/usr/local/lib

 

7. Get the result file in the current directory

Proto****.proto

Proto****.pb.h

Proto****.pb.cc

 

8. Enjoy it

 

您可以通过以下步骤在Linux上下载和安装Protobuf: 1. 首先,您可以从Protobuf的GitHub仓库下载不同版本的压缩包。 2. 推荐下载cpp版本的压缩包,例如protobuf-cpp-3.11.4.zip。 3. 下载完成后,您可以使用以下命令进行编译和安装: - 解压缩下载的压缩包:unzip protobuf-cpp-3.11.4.zip - 进入解压缩后的目录:cd protobuf-3.11.4/ - 配置编译选项,指定安装路径:./configure --prefix=/home/protobuf/ - 使用多线程进行编译:make -j8 - 运行测试以确保编译成功:make check - 安装Protobuf到指定路径:make install 关于如何使用Proto文件生成C++对应的.pb.h/.pb.cc文件,您可以参考一篇文章,其中提供了相关方法和步骤:【ProtoBufProtoBuf 通过proto文件生成cc/h文件。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [protobuflinux下载编译和使用](https://blog.csdn.net/weixin_57023347/article/details/127082681)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* *3* [【ProtobufLinux 下源码编译 Protobuf 库](https://blog.csdn.net/unonoi/article/details/131817640)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值