金庆的专栏

  C++博客 :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  423 随笔 :: 0 文章 :: 454 评论 :: 0 Trackbacks
rpcz VC2010 构建


rpcz 是应用ZeroMQ和Protobuf开发的RPC.

见: https://github.com/reinferio/rpcz

及 https://code.google.com/p/rpcz/


rpcz的CMake脚本应该是仅用于Linux. 用于VC需要更改错误。

CMake Error at D:/Program Files/CMake 2.8/share/cmake-2.8/Modules/FindBoost.cmake:1192 (message):
  Unable to find the requested Boost libraries.
如果找不到boost_thread库,添加
SET(Boost_USE_STATIC_LIBS TRUE)
因为Windows下Boost默认是不生成动态库的。

Required library ZeroMQ NOT FOUND.
Could NOT find PROTOBUF (missing:  PROTOBUF_LIBRARY PROTOBUF_INCLUDE_DIR)
可手工在cmake-gui中设置ZeroMQ的INCLUDE_DIR和LIBRARY, 以及protobuf的源码目录.

CMake生成sln后, 用VC打开, 构建.
cl : Command line error D8021: invalid numeric argument '/Wextra'

将gcc编译参数用if包括:
+if(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS
  "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-sign-compare -Wno-unused-parameter")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -g -Werror")
+endif(CMAKE_COMPILER_IS_GNUCXX)

application.cc(18): fatal error C1083: Cannot open include file: 'zmq.hpp': No such file or directory
需要设置 cppzmq 目录.
添加CPPZMQ_DIR.
或者直接 include_directories(E:/JinQing/Src/cppzmq)

src\rpcz/rpcz.pb.h(293): error C2059: syntax error : 'constant'
生成的代码 NO_ERROR 与VC Error.h 中的 define 冲突.
改为 APPLICATION_NO_ERROR 常量,不会与宏冲突。

  clock.cc
..\..\..\..\LibSrc\rpcz\src\rpcz\clock.cc(18): fatal error C1083: Cannot open include file: 'sys/time.h': No such file or directory
将gettimeofday()改为:
    return boost::chrono::high_resolution_clock().now().time_since_epoch().count / 1000000;

  connection_manager.cc
..\..\..\..\LibSrc\rpcz\src\rpcz\connection_manager.cc(25): fatal error C1083: Cannot open include file: 'pthread.h': No such file or directory
DELETE

  connection_manager.cc
..\..\..\..\LibSrc\rpcz\src\rpcz\connection_manager.cc(28): fatal error C1083: Cannot open include file: 'unistd.h': No such file or directory
改为:
#ifdef WIN32
#include <process.h>  // for getpid()
#else
#include <unistd.h>  // for getpid()
#endif

..\..\..\..\LibSrc\rpcz\src\rpcz\reactor.cc(122): error C2079: 'action' uses undefined struct 'rpcz::install_signal_handler::sigaction'
..\..\..\..\LibSrc\rpcz\src\rpcz\reactor.cc(125): error C3861: 'sigemptyset': identifier not found
改为:
void install_signal_handler() {
#ifdef WIN32
  signal(SIGINT, signal_handler);
  signal(SIGTERM, signal_handler);
#else
  struct sigaction action;
  action.sa_handler = signal_handler;
  action.sa_flags = 0;
  sigemptyset(&action.sa_mask);
  sigaction(SIGINT, &action, NULL);
  sigaction(SIGTERM, &action, NULL);
#endif  // WIN32
}


  server.cc
..\..\..\..\LibSrc\rpcz\src\rpcz\server.cc(20): fatal error C1083: Cannot open include file: 'sys/errno.h': No such file or directory
DELETE

  zmq_utils.cc
D:/LibSrc/rpcz/include\rpcz/zmq_utils.hpp(58): error C2146: syntax error : missing ';' before identifier 'has_more_'
改为int

------ Build started: Project: rpcz, Configuration: Release Win32 ------
LINK : fatal error LNK1104: cannot open file 'libboost_date_time-vc100-mt-1_53.lib'
Add lib dir.

3>------ Build started: Project: zsendrpc, Configuration: Debug Win32 ------
3>  zsendrpc.cc
3>LINK : fatal error LNK1104: cannot open file 'Debug\rpcz.lib'
仅生成rpcz.dll, 没有lib. 因为没有export.
应该生成静态库.
开启 rpcz_build_static
并且让zsendrpc在rpcz.lib之后编译:

    add_dependencies(zsendrpc rpcz_static)  # zsendrpc need rpcz.lib

修改后的代码见:

https://github.com/jinq0123/rpcz
posted on 2013-12-08 21:19 金庆 阅读(2350) 评论(0)  编辑 收藏 引用 所属分类: 1. C/C++2. 网游开发

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理