zoukankan      html  css  js  c++  java
  • protobuf 系列 ---------下载、编译与使用

             protobuf是谷歌开发并开源的二进制序列化工具,比常用的xml,json体积更小,解析速度更快。

             

             目前,手头上的项目有涉及到这个工具,打算仔细研究一番,顺带记录遇到的问题,解决方法,时间足够的话,深入探究下源码。

             今天主要记录下怎么下载源码,怎么成功编译。本人的平台是windows,编译器用的是vs2010。

             源码下载:https://github.com/google/protobuf.git

             本人下载到本地目录为:E:codeprotobufstudygithub

             

            下载完成后的目录结构如上。

            怎么编译的话里面有份文档解释的非常清楚

           

          

           考虑到有些人不喜欢看英文,我再把我的编译过程展示下。

           一:前期准备:CMake工具,可以去官网下载二进制版本的。https://cmake.org/download/

           

              安装到本地后,如 C:Program FilesCMakein ,然后打开命令行设置下环境变量E:codeprotobufstudygithub>set PATH=%PATH%;C:Program Files (x86)CMakein

              (ps:命令行最好切换到下载的源码目录下,这样与本人讲述的一致)

              这时就能使用cmake命令了,否则会说cmake不是内部命令什么的。

              然后进入源码目录,E:codeprotobufstudygithub>cd trunk
                                       E:codeprotobufstudygithub runk>

              进入源码下面的cmake目录,E:codeprotobufstudygithub runk>cd cmake

                                                  E:codeprotobufstudygithub runkcmake>

               创建build目录,E:codeprotobufstudygithub runkcmake>mkdir build & cd build

                                    E:codeprotobufstudygithub runkcmakeuild>

               创建solution目录, E:codeprotobufstudygithub runkcmakeuild>mkdir solution & cd solution

                                         E:codeprotobufstudygithub runkcmakeuildsolution>

               执行cmake指令,cmake -G "Visual Studio 10 2010 Win64" ^

                                               -DCMAKE_INSTALL_PREFIX=../../../../install ^
                                                ../..                 (暂且叫cmake指令1)                    

               如果会报错误,找不到cl.exe,请设置下cl.exe的环境变量

               E:codeprotobufstudygithub runkcmakeuildsolution>set PATH=%PATH%;C:Program Files (x86)Microsoft Visual Studio 11.0VCin  (这个是你本地的cl.exe所在目录)

               再次执行cmake指令1,如果还报错误,找不到mspdb100.dll,请设置下mspdb100.dll的环境变量

               E:codeprotobufstudygithub runkcmakeuildsolution>set PATH=%PATH%;D:Program Files (x86)Microsoft Visual Studio 10.0Common7IDE  (这个是你本地的mspdb100.dll所在目录)

               再次执行cmake指令1,如果还报错误,没有找到gmock目录,要么下载下gmock,https://github.com/google/googlemock.git 目录为E:codeprotobufstudygithub runkgmock,

               本人懒,没有下载,那么久更改下cmake执行。

               执行cmake指令,cmake -G "Visual Studio 10 2010 Win64" ^

                                                -Dprotobuf_BUILD_TESTS=OFF ^

                                               -DCMAKE_INSTALL_PREFIX=../../../../install ^
                                                ../..                 (暂且叫cmake指令2)      

                这时在solution目录下就会有相应的.sln了。

                

                            打开编译即可,本人编译的release,编译的成果

                            

           

              

  • 相关阅读:
    leetcode教程系列——Binary Tree
    《Ranked List Loss for Deep Metric Learning》CVPR 2019
    《Domain Agnostic Learning with Disentangled Representations》ICML 2019
    Pytorch从0开始实现YOLO V3指南 part5——设计输入和输出的流程
    Pytorch从0开始实现YOLO V3指南 part4——置信度阈值和非极大值抑制
    Pytorch从0开始实现YOLO V3指南 part3——实现网络前向传播
    Pytorch从0开始实现YOLO V3指南 part2——搭建网络结构层
    Pytorch从0开始实现YOLO V3指南 part1——理解YOLO的工作
    让我佩服的人生 文章
    win8.1配置cordova+ionic等一系列东西
  • 原文地址:https://www.cnblogs.com/xuhuajie/p/6890252.html
Copyright © 2011-2022 走看看