xp下使用thrift
2015-07-31 16:56
399 查看
从服务器上来看,thrift最早的版本为thrift0.6.0,在2011年发布的。thrift并不是很重视windows的用户,知道0.8.0版本才支持windows下编译。其中,相关文档也不更新,开发使用起来确实有点无奈~
尤其对xp版本的相关文档少之又少,正常在win7开发完的动态库客户端接口在win7下不能用,同时boost也要重新编译,所调用的库不一样。
为了便于其他人在xp下使用thrift,需要改以下内容,进入到thrift-0.8.0\lib\cpp\src\windows修改为如下代码:
bjam.exe --toolset=msvc-10.0 architecture=x86 address-model=32 link=static --build-type=complete --with-system --with-thread --with-date_time --with-filesystem --with-serialization release
好了~~这样就可以正常使用了~~~如有问题再留言~~
尤其对xp版本的相关文档少之又少,正常在win7开发完的动态库客户端接口在win7下不能用,同时boost也要重新编译,所调用的库不一样。
为了便于其他人在xp下使用thrift,需要改以下内容,进入到thrift-0.8.0\lib\cpp\src\windows修改为如下代码:
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ #ifndef _THRIFT_WINDOWS_CONFIG_H_ #define _THRIFT_WINDOWS_CONFIG_H_ 1 #if defined(_MSC_VER) && (_MSC_VER > 1200) #pragma once #endif // _MSC_VER #ifndef _WIN32 #error This is a MSVC header only. #endif #pragma warning(disable: 4996) // Depreciated posix name. #pragma warning(disable: 4250) // Inherits via dominance. #define VERSION "0.8.0" #define HAVE_GETTIMEOFDAY 1 #define HAVE_SYS_STAT_H 1 #include "TargetVersion.h" #include "GetTimeOfDay.h" #include "Operators.h" #include "TWinsockSingleton.h" #include "WinFcntl.h" #include "SocketPair.h" // boost #include <boost/cstdint.hpp> typedef boost::int64_t int64_t; typedef boost::uint32_t uint32_t; typedef boost::uint8_t uint8_t; // windows #include <Winsock2.h> #include <ws2tcpip.h> #pragma comment(lib, "Ws2_32.lib") // pthreads #if 0 # include <pthread.h> #else struct timespec { int64_t tv_sec; int64_t tv_nsec; }; # define USE_BOOST_THREAD 1 # define ctime_r( _clock, _buf ) \ ( strcpy( (_buf), ctime( (_clock) ) ), \ (_buf) ) #endif typedef ptrdiff_t ssize_t; // Missing functions. #define usleep(ms) Sleep(ms) #if WINVER <= 0x0502 #define poll(fds, nfds, timeout) \ poll_win32(fds, nfds, timeout) inline int poll_win32(LPWSAPOLLFD fdArray, ULONG fds, INT timeout) { fd_set read_fds; fd_set write_fds; fd_set except_fds; FD_ZERO(&read_fds); FD_ZERO(&write_fds); FD_ZERO(&except_fds); FD_SET(fdArray[0].fd, &read_fds); FD_SET(fdArray[0].fd, &write_fds); FD_SET(fdArray[0].fd, &except_fds); timeval time_out = {timeout * 0.001, timeout * 1000}; return select(1, &read_fds, &write_fds, &except_fds, &time_out); } #else //新加入的 inline int poll(LPWSAPOLLFD fdArray, ULONG fds, INT timeout) { fd_set read_fds; fd_set write_fds; fd_set except_fds; FD_ZERO(&read_fds); FD_ZERO(&write_fds); FD_ZERO(&except_fds); FD_SET(fdArray[0].fd, &read_fds); FD_SET(fdArray[0].fd, &write_fds); FD_SET(fdArray[0].fd, &except_fds); timeval time_out = {timeout * 0.001, timeout * 1000}; return select(1, &read_fds, &write_fds, &except_fds, &time_out); } <span style="white-space:pre"> </span>//所需要屏蔽掉的 //inline int poll(struct pollfd* fdArray, ULONG fds, INT timeout) { // return WSAPoll(fdArray, fds, timeout); //} #endif // WINVER inline void close(SOCKET socket) { ::closesocket(socket); } #endif // _THRIFT_WINDOWS_CONFIG_H_修改完之后还要重新编译一版boost,编译脚本如下:
bjam.exe --toolset=msvc-10.0 architecture=x86 address-model=32 link=static --build-type=complete --with-system --with-thread --with-date_time --with-filesystem --with-serialization release
好了~~这样就可以正常使用了~~~如有问题再留言~~
相关文章推荐
- iOS学习----------正则表达式
- 第 2 章 使用数据库管理用户权限
- 引子
- 关于CLR、CIL、CTS、CLS、CLI、BCL和FCL。
- CSS让div背景透明
- java 堆栈 静态
- apache用户认证访问机制(转)
- Oracle修改字段长度以及计算天数
- 编译器括号检查原理(C)
- 【PHP】PHP中__get()和__set()的用法实例详解
- 黑马程序员----java基础面向对象特点及封装
- 用WINRAR将.bat文件转为自启动
- 观看maven视频记录
- 梯度下降法
- 第 3 章 自定义数据库表结构
- js如何使得新打开的窗口居中
- 二维码zxing源码分析(一)camera部分
- Ueditor使用方法
- 【发问】代表ODBC、Ibatis 发问 Hibernate、Linq、Entity、JPA
- 逐帧动画(Frame-by-frame Animations)