一.protobuf 安装

protobuf版本:2.6.1

下载地址:https://github.com/google/protobuf/archive/v2.6.1.zip

解压之后进入目录

修改autogen.sh

echo "Google Test not present.  Fetching gtest-1.5.0 from the web..."
curl http://googletest.googlecode.com/files/gtest-1.5.0.tar.bz2 | tar jx
mv gtest-1.5.0 gtest

autogen.sh内的上述内容修改为

wget https://github.com/google/googletest/archive/release-1.5.0.tar.gz
tar xzvf release-1.5.0.tar.gz
mv googletest-release-1.5.0 gtest

然后执行autogen.sh

./autogen.sh

目录中就会生成出.configure文件

接着运行

./configure
make
make check
make install

设置环境变量

sudo vi /etc/profile
export PATH=$PATH:/usr/local/bin
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
cd ~
vi .profile
export PATH=$PATH:/usr/local/bin
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig

配置动态链接库路径

sudo vi /etc/ld.so.conf
include /usr/local/lib
 sudo ldconfig

二.编写CMakeLists

cmake_minimum_required (VERSION 2.8)

project (Demo1)
SET(SRC_LIST test1.cpp)
# Find required protobuf package
find_package(Protobuf REQUIRED)
if(PROTOBUF_FOUND)
message(STATUS "protobuf library found")
else()
message(FATAL_ERROR "protobuf library is needed but cant be found")
endif()
include_directories(${PROTOBUF_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
PROTOBUF_GENERATE_CPP(PROTO_SRCS PROTO_HDRS test1.proto) ADD_EXECUTABLE(Demo1 ${SRC_LIST} ${PROTO_SRCS} ${PROTO_HDRS}) target_link_libraries(Demo1 ${PROTOBUF_LIBRARIES}) #add_executable(Demo test1.cpp)

如果你觉得对你有用请付款

最新文章

  1. IntelliJ IDEA 2016.2激活方法
  2. 设置SecureCRT会话的缓冲区大小
  3. UVa 11388 & 丝帛
  4. 《Java程序设计》第十周学习总结
  5. 详解定位—>"position"
  6. python os模块sys模块常用方法
  7. 26.怎样在Swift中定义宏?
  8. PrettyProgressBar
  9. 阅读:DBA们不得不知的数据库硬件RAID常识
  10. 如何用思维导图快速理解PMBOK-PMP第六版教材
  11. poj2817状态压缩 升维
  12. Android生成二维码--保存和分享二维码图片
  13. gnome extensions 推荐 (fedora 28 常用gnome 插件备份)
  14. [已解决]An unhandled exception occurred while processing the request.
  15. java实现网页验证码
  16. TestNG源代码分析:依赖管理的实现
  17. eclipse中类和方法添加作者日期说明
  18. c# Stream to File的知识点
  19. MySQL中having与where
  20. arcgis for flex 学习笔记(一)

热门文章

  1. cacti 安装与 与不能显示图像故障解决方案
  2. mysql存储过程模板
  3. 路飞学城知识点4之Django contenttypes 应用
  4. HTML后续
  5. Windows下Git服务端和客户端的搭建
  6. Java学习---基础知识学习
  7. Linq使用技巧及查询示例(一)
  8. Nowcoder Girl 初赛 T5
  9. Vim 编辑器及其基本操作
  10. JavaScript 数组遍历方法的对比