vc2015编译protobuf

下载地址:https://github.com/google/protobuf

1.编译
通过cmake生成sln文件来编译
用cmd命令 cd 到3.0.0-beta-4\cmake

mkdir build & cd build
mkdir solutionx86 & cd solutionx86
cmake -G "Visual Studio 14 2015" -DCMAKE_INSTALL_PREFIX=../../../../install ../.. -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_BUILD_SHARED_LIBS=ON -DCMAKE_GENERATOR_TOOLSET=v140_xp

如果要编译64位的话

cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_INSTALL_PREFIX=../../../../install ../.. -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_BUILD_SHARED_LIBS=ON -DCMAKE_GENERATOR_TOOLSET=v140_xp

注意中间不能有回车之类的,该命令行生成的是dll版本的(静态库的话要注意lib的运行库),其它版本请查考cmake目录下面的README.md

2.hello world

将examples目录下满的addressbook.proto,拷贝到生成的protoc.exe目录下面,cd到该目录

protoc --cpp_out=./ addressbook.proto

这样就会生成addressbook.pb.cc , addressbook.pb.h  两个文件,包含到你的项目中

addressbook.pb.cc,需要取消预编译头或者手动加入#include "stdafx.h"

然后包含头文件和lib文件

直接用examples目录下面的 add_person.cc里面的代码测试即可

注意:使用dll的时候需要定义宏PROTOBUF_USE_DLLS,小心不要将这个PROTOBUF_USE_DLLS定义在stdafx.h里面,然后你又取消了预编译头!

时间: 2024-08-10 17:01:32

vc2015编译protobuf的相关文章

Windows下编译protobuf v3.3.0

一:概述 关于 protobuf 在此不再多说,此处记录下成功编译步骤以备日后查阅.注意:本文并不是使用cmake gui进行编译的,如果熟悉cmake gui的话,也可以使用gui进行生成编译. 二:准备资源及工具 VS2013或以上版本,安装好 protobuf 源码,下载地址:官网:http://code.google.com/p/protobuf/git网:https://github.com/google/protobuf或git:https://github.com/google/p

VS2013编译protobuf报错:error C4996: 'std::_Copy_impl': Function call with parameters that may be unsafe

今天碰到这个问题,网上找了好久, 解决方法如下 VS2013编译protobuf报错:error C4996: 'std::_Copy_impl': Function call with parameters that may be unsafe 方法一 右键点击工程 -> 属性 -> C/C++ -> 常规 -> SDL检查 改为:否 (/sdl-) 编译 O了! 方法二 右键点击工程 -> 属性 -> C/C++ ->预处理器 添加宏定义 _SCL_SECUR

ubuntu下编译protobuf

参考: http://blog.csdn.net/wuzuyu365/article/details/51900676 1.下载protobuf下载地址:https://github.com/google/protobuf 目前最新稳定版是2.6.1 一般下载 protobuf-2.6.1.tar.bz2 或者protobuf-2.6.1.tar.gz 2.编译protobuf解压下载的压缩包,cd到protobuf的目录下,执行以下指令:./configuremakemake checkmak

编译protobuf的jar文件

1.准备工作 需要到github上下载相应的文件,地址https://github.com/google/protobuf/releases protobuf有很多不同语言的版本,因为我们需要的是jar文件,所以选择java版本下载.以下以版本3.1.0进行举例说明. 如果是在linux64环境下编译,可以选择以下两个文件,第一个相当于java发行版本的源码文件,第二个是一个编译好的protoc程序文件(如果想自己编译protobuf程序文件,参考上篇文章protobuf的编译安装). prot

vs编译protobuf 3.0.0

Google终于发布了protobuf 3.0的release版了,升级项就不说了,之前的版本内部都有一个vsprojects目录,可以通过vs工程直接打开,新版本需要自己通过cmake去创建. protobuf下载地址:https://github.com/google/protobuf/releases/tag/v3.0.0: cmake下载地址: https://cmake.org/download/ cmake安装成功后打开cmake(cmake-gui),设置如下: 分别选择proto

linux下编译protobuf(可以编译成pb.go)

参考 :https://blog.csdn.net/xiexievv/article/details/47396725 下载代码  : git clone https://github.com/google/protobuf 进入目录 : cd prootbuf ./autogen.sh      $ ./configure  --prefix=<安装路径>      $ make  $ make check $ make install 到此步还没有安装完毕,在用户目录 ~/.bash_pr

Boost1.61+win7+VC2015编译

下载 通过boost官方网站, 或直接在source forge下载boost_1_61_0. 可选包 Zlib library, 环境变量: ZLIB_SOURCE bzip2, 环境变量: BZIP2_SOURCE ICU i18n, 环境变量HAVE_ICU=1, ICU_PATH expat, 环境变量: EXPAT_INCLUDE (头文件包含目录) 和 EXPAT_LIBPATH (库目录) 在Windows上编译Boost 下载完Boost源文件压缩包后, 创建boost-src目

Ubuntu编译Protobuf(Base tensorflow-12)报错

报错1: [email protected]:~/dogecoin$ ./autogen.sh./autogen.sh: 50: ./autogen.sh: autoreconf: not found 参考: https://github.com/dogecoin/dogecoin/issues/529 sudo apt-get install autoconf 报错2: configure.ac:30: error: possibly undefined macro: AC_PROG_LIBT

protobuf在ios的编译

原来大体思路是先在mac上编译protobuf生成protoc工具, 然后分不同CPU编译,最后用lipo生成胖a文件 CPU顺序为 i386, armv7 ... 生成armv7时候总是莫名其妙的报不同CPU类型的错误,错误在.libs文件夹总的o文件上 尝试每次调用不同CPU之前调用 find . -name .libs | xargs rm -rf 结果连i386都编译不过去了 由此得到要给结论,第一步生成protoc工具后并不是只需要protoc这个工具还包括在libs中的一些中间文件也