使用Cygwin(下载、安装)编译Protocol Buffers v2.6.1

     编译了Protocol Buffers最新版本,失败,未查明原因,2.6.1版本成功~

     准备内容:

      1、下载Protobuf源码:http://github.com/google/protobuf/releases在网址中找到v2.6.1版本下载

      2、下载Cygwin最新版本,并安装

            安装Cygwin:

            在http://www.cygwin.com/中下载Cygwin的64位安装包setup-x86 64.exe,下载完成后打开安装,首先是初始界面

            

            点击下一步

            

            默认Install from Internet,再点击下一步

            

            更改存放路径,我选择放在了D盘下,使用权限是for all users,继续下一步

            

            选择存放它下载的安装文件目录,依然是D盘cygwin文件夹下,继续下一步

            

            选择默认的直接链接,继续下一步

            

            进入网址选择,其实开始是没有第一个地址的,需要在User URL中添加地址http://mirrors.163.com/cygwin/,这是我在一个博客上看到的cygwin的在线安装最快的镜像,确实比它下面一个地址快很多,博客的原地址:http://blog.csdn.net/rodulf/article/details/52488280,继续下一步

            

            进入到了Cygwin的选择包的界面,在view里面选择Category中的Devel展开,保持current状态下,在Devel展开项里选择gcc-core:GUN Compiler Collection(C,OpenMP)、make:The GU86N version of the'make'utility和mingw64-gcc-g++:GCC for Win32(i6886-w64-mingw32) toolchain(C++)三项安装,继续下一步,开始安装。

            

            添加图标和开始按钮,点击完成,安装即完成。

            

            将环境变量添加进去,把原有的MinGW相关的环境变量都删除。

 

            至此,第二项准备内容,Cygwin的下载和安装完成。可以使用cmd,输入gcc -v查看gcc的安装结果

                 

      开始编译:

      1、Follow上文说的C++ Installation - Unix开始编译,地址:https://github.com/google/protobuf/blob/master/src/README.md

            

            因为已经下载了源码,可以直接从这里开始

            

      2、打开下载并安装完成的Cygwin64 Terminal,出现界面:

            

            进入下载好的Protocol Buffers的目录

            

      3、开始配置,输入./configure 

            

      4、开始编译,输入make,注意:如果之前安装Cygwin时没有安装make这里会提示没有make这个command。

            

            在运行make时,出现了一个bug,No suitable threading library available,在网上找到了问题所在,原博客地址:http://618119.com/tag/protobuf

            原因是因为改环境变量的时候没有去掉MinGW的bin目录,导致无法识别Cygwin自带的pthread库,这个bug在配置./configure的时候就有表现,make不成功时configure的记录是:

              checking for library containing zlibVersion… -lz
              checking for the pthreads library -lpthreads… no
              checking whether pthreads work without any flags… no
              checking whether pthreads work with -Kthread… no
              checking whether pthreads work with -kthread… no
              checking for the pthreads library -llthread… no
              checking whether pthreads work with -pthread… no
              checking whether pthreads work with -pthreads… no
              checking whether pthreads work with -mthreads… no
              checking for the pthreads library -lpthread… no
              checking whether pthreads work with –thread-safe… no
              checking whether pthreads work with -mt… no
              checking for pthread-config… no

            运行make成功时:

              checking for the pthreads library -lpthreads… no
              checking whether pthreads work without any flags… yes
              checking for joinable pthread attribute… PTHREAD_CREATE_JOINABLE
              checking if more special flags are required for pthreads… no
              checking whether to check for GCC pthread/shared inconsistencies… no
              checking whether what we have so far is sufficient with -nostdlib… no
              checking whether -lpthread saves the day… no
              configure: WARNING: Impossible to determine how to use pthreads with shared libraries and -nostdlib

      5、make check:

            

            安装指南里面也写了如果make check失败了依然可以install,但是一些库可能不能正常使用:        


      6、make install(因为Cygwin是最高权限,所以可以不需要添加sudo,直接执行命令make install)

            

            至此,编译Protocol Buffers v2.6.1成功。

      查看生成文件:

      1、在目录D:\ProtocolBuffers\protobuf-2.6.1\src\.libs下查看生成的.a文件


      2、在目录D:\cygwin\usr\local\include\google\protobuf下查看所有需要的头文件

            至此,使用Cygwin编译Protocol Buffers v2.6.1全部完成,不过这个生成的库文件在Qt中使用时.cc文件编译无法通过,想要在Qt中使用Protocol Buffers请详见另一篇博文,使用Qt自带MinGW+msys编译Protocol Buffers。           

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值