1. Dev C++
2. boost 1.53.0 (我下的 1.69.0 也可以过编译)
3. Flex & Bison
下载地址:
https://sourceforge.net/projects/winflexbison/files/latest/download
https://jaist.dl.sourceforge.net/project/winflexbison/win_flex_bison-latest.zip
4. 源代码
5.libevent (编译64位)
thrift 的 cmake 配置:
6.OpenSSL (编译64位)
thrift的 cmake 配置:
郑重声明: 编译64位的thrift 需要编译64位的 libevent 和 OpenSSL !
1.设置源码、生成目录的路径。
2.设置变量路径:
Boost_INCLUDE_DIR boost 引用目录
BISON_EXECUTABLE bison 程序路径
FLEX_EXECUTABLE flex 程序路径
CMAKE_CXX_COMPILER g++ 程序路径
CMAKE_MAKE_PROGRAM mingw32-make 程序路径
BUILD_TUTORIALS 这个构去掉, 这是编译 教程 。
CMAKE_INSTALL_PREFIX 库的安装路径
CMAKE_BUILD_TYPE 设置为Release
With_LibEvent 开启
With_OpenSSL 开启
Shared_lib 开启,生成 dll,否则不生成DLL哦。
cmd 进入到生成目录; 添加 make 程序的路径到PATH环境变量:
SET PATH=%PATH%;C:\Program Files (x86)\Dev-Cpp\MinGW64\bin\
开始编译并安装:
mingw32-make -j4 install
4.遇到的问题&解决:
1.
C:\Users\myuser\Downloads\thrift-master\lib\cpp\src\thrift\transport\THttpServer.cpp: In member function 'std::string apache::thrift::transport::THttpServer::getTimeRFC1123()':
C:\Users\myuser\Downloads\thrift-master\lib\cpp\src\thrift\transport\THttpServer.cpp:43:66: error: 'gmtime_s' was not declared in this scope
#define THRIFT_GMTIME(TM, TIME) gmtime_s(&TM, &TIME)
和编译 ollvm 遇到相同问题, 直接注释掉。
(为了避免未来出错,不要注释代码。) 加入 头文件 time.h 可以解决。
2.
C:\Users\myuser\Downloads\thrift-master\lib\cpp\src\thrift\transport\TFileTransport.cpp: In member function 'void apache::thrift::transport::TFileTransport::writerThread()':
C:\Users\myuser\Downloads\thrift-master\lib\cpp\src\thrift\transport\TFileTransport.cpp:324:45: error: '_chsize_s' was not declared in this scope
if (0 == THRIFT_FTRUNCATE(fd_, offset_)) {
^
搜索源码发现:
thrift-master\lib\cpp\src\thrift\transport\PlatformSocket.h
# define THRIFT_FTRUNCATE _chsize_s
添加 io.h 文件的引用:
C:\Users\myuser\Downloads\thrift-master\lib\cpp\src\thrift\transport\PlatformSocket.h
#ifndef _THRIFT_TRANSPORT_PLATFORM_SOCKET_H_
# define _THRIFT_TRANSPORT_PLATFORM_SOCKET_H_
#define _WIN32 1
#ifdef _WIN32
# include
# include
同时,\thrift-master\lib\cpp\src\thrift\transport\TFileTransport.cpp
文件需要添加 PlatformSocket.h 文件的引用 。
搜索 _chsize_s 的 msdn,发现引用IO.h ,但事实上没有这个函数。
这个是 secured 的函数, 换成 _chsize ,坑的一B。
# define THRIFT_FTRUNCATE _chsize
附录:
我编译好的 Win64 位带有 Non blocking 的 thrift库(内含thrift编译器exe、dll、a文件):
链接:https://pan.baidu.com/s/1acHysRZ1v0CJYy8BcaJsGQ
提取码:1lev
太菜了,编译这些开源项目花了好几天……