1、编译ace-6.0.2
win32
在$ace_root$ace下面增加config.h文件,添加内容如下
#pragma once
//#define ACE_USES_WCHAR //使用unicode字符集
#define ACE_HAS_MFC 1 //是否使用mfc
#include "ace/config-win32.h"
打开对应的项目/工程文件,编译
在default_constants.h中修改
# if !defined (ACE_DEFAULT_ASYNCH_BACKLOG)
# define ACE_DEFAULT_ASYNCH_BACKLOG SOMAXCONN/*5更改最大*/
# endif /* ACE_DEFAULT_ASYNCH_BACKLOG */
linux
#tar -jxf ACE-xxx.tar.bz2
加环境变量
export ACE_ROOT=/home/lsl/ACE_wrappers
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ACE_ROOT/ace
到用户的pro
#cd /home/userxxx/ACE_wrapper
#mkdir build
#cd build
#../configure --enable-ssl=no --enable-gperf=no --enable-static=yes --cache-file=linux.cache
--enable-ssl表示openssl支持
--enable-gperf表示gperf库支持
--enable-static表示编译静态库,默认只编译动态库,考虑开发使用可能会用到静态版本
--cache-file表示配置脚本输出的结果文件,中断后继续执行配置脚本时可节省时间
configure过程中如果出现event poll测试失败,执行
echo "ace_cv_linux_event_poll=true" > linux.cache
然后继续configure
最后#make && make install
2、使用
(1)编写使用了ACE的代码
(2)编写Makefile
BIN = hello_ace
FILES = Piece2 Piece3
SRC= $(addsuffix .cpp,$(FILES))
OBJ= $(addsuffix .o,$(FILES))
BUILD = $(VBIN)
#---------------------------------------------------------
# Include macros and targets
#---------------------------------------------------------
include $(ACE_ROOT)/include/makeinclude/wrapper_macros.GNU
include $(ACE_ROOT)/include/makeinclude/macros.GNU
include $(ACE_ROOT)/include/makeinclude/rules.common.GNU
include $(ACE_ROOT)/include/makeinclude/rules.nonested.GNU
include $(ACE_ROOT)/include/makeinclude/rules.bin.GNU
include $(ACE_ROOT)/include/makeinclude/rules.local.GNU
以上的Makefile包含3个cpp文件hello_ace.cpp、Piece2.cpp和Piece3.cpp
(3)编译#make
win7, ace-6.0.2, vs2008sp1,vs2010
设置如下:
- Set the
DE> SSL_ROOT DE> environment variable to the location of the directory containing the OpenSSL DE> inc32 DE> and DE> out32dll DE> directories.
- Add
DE> ssl=1 DE> to your MPC DE> $ACE_ROOT/bin/MakeProjectCreator/config/default.features DE> or DE> $ACE_ROOT/local.features DE> file, and re-run MPC to add support for building the ACE_SSL library to your MSVC++ workspaces and projects.
- Open the
DE> ACE.sln DE> solution, and refer to the ACE build and installation instructions above for details on creating a DE> config.h DE> configuration header for this platform. On ce the DE> config.h DE> file has been created, build the DE> ACE_SSL DE> project.
ACE和MFC配合,或者使用mpc生成工程
在Windows下安装Perl环境,然后重启。然后执行下面命令
cd %ACE_ROOT%
perl bin\mwc.pl -type vc9 -value_template "configurations = 'MFC Release' 'MFC Debug' Release Debug" ace/ace.mwc
然后打开%ACE_ROOT%/ace/ace.sln,编译MFC两个工程,生成ACEmfc.lib及dll就可以了,然后使用前调用:ACE::init(),使用后调用 ACE::fini()。