ACE的编译和安装,for windows、Linux

ACE的编译和安装,for windows、Linux2006-10-11 09:14from www.acejoy.com ACE网络编程开发论坛

一. Windows下for MSVC的安装与配置
我们用的是ACE-5.4+TAO-1.4+CIAO-0.4.zip,Windows下解压缩该压缩包到目标路径(设为D:\ACE_wrappers ),

创建文件:$ACE_ROOT/ace/config.h,增加一行:
#include "ace/config-win32.h"

如果是在Windows 9x/Me下,需要在$ACE_ROOT/ace/config.h中#include语句前加入:
#define ACE_HAS_WINNT4 0

如果想使用standard C++ header,需要在$ACE_ROOT/ace/config.h中#include语句前加入:
#define ACE_HAS_STANDARD_CPP_LIBRARY 1

如果想把MFC作为静态库链接到ACE(If you prefer to link MFC as a static library into ACE),
则需要在$ACE_ROOT/ace/config.h中#include语句前加入:
#define ACE_HAS_MFC 1

如果想生成ACE静态库或在工程中使用ACE静态库,都需要定义以下宏:
ACE_AS_STATIC_LIBS


打开工程,D:\ACE_wrappers\ace.dsw,编译生成以下库:

ace.dll/ace.lib (DLL release)
aced.dll/aced.lib(DLL debug)
acemfc.dll/acemfc.lib (MFC DLL release)
acemfcd.dll/acemfcd.lib(MFC DLL debug)

aces.lib (Static library release)
acesd.lib (Static library debug)

这些库可分别实现了Debug/Release, MFC/Non-MFC, Static/Dynamic library.

其中前四个的dll在D:\ACE_WRAPPERS\bin目录下, 所有对应的.lib库文件在D:\ACE_WRAPPERS\ace下。

ACE是网络通讯中间件,如果机器没有装网卡,就仿真一个,比如可以从控制面板选装MS Loopback Adapter。

接下来我们创建一个新的工程,如果机器上装了不同版本的ACE,需要针对某个版本配置,方法如下:

1. 配置C/C++ tab

(1) Code Generation category中应选择合适的选项:
Multithreaded和Multithreaded DLL是for Release版的
Debug Multithreaded和Debug Multithreaded DLL是for Debug版的

(2) $(ACE_ROOT)路径的配置:
如果需要针对不同版本ACE灵活配置的话,则需要设置Preprocessor category中"Additional include directories"
这一项,指明特定版本ACE所在的路径,比如D:\ACE_wrappers

2. 链接到特定版本的ACE库。

(1) 在Project/Setting/Link的Input category下 "Additional library path"中增加特定版本的ACE库文件路径,
比如D:\ACE_wrappers\ace,然后将D:\ACE_wrappers\bin目录下对应的dll拷贝到工程文件所在路径下,或者在环境
变量PATH中加入D:\ACE_wrappers\bin。

(2) 在Project/Setting/Link的Input category下"Object/library modules" 中指定需要包含的ACE库(*.lib)


如果只装了一个ACE,可采用对所有工程都生效的缺省配置,方法如下:

1. 添加环境变量:
ACE_ROOT: D:\ACE_wrappers
PATH 中加入:D:\ACE_wrappers\bin

2. 设置VS的路径:
Include files包含:D:\ACE_wrappers
library files包含:D:\ACE_wrappers\ace

此后,就可以在工程中指定需要包含的ACE库(*.lib)后正常使用了。


二. Linux下的安装与配置
1.安装
以用户aceuser为例
(1)下载ACE-5.4+TAO-1.4+CIAO-0.4.tar.gz(其它版本的也一样)


(2)解压之
#cd /home/aceuser/ace
#tar -xzvf ACE-5.4+TAO-1.4+CIAO-0.4.tar.gz

(3)
#vi /home/aceuser/.bashrc
加入下面两行:
export ACE_ROOT=/home/aceuser/ace/ACE_wrappers
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ACE_ROOT/ace

并使这些环境变量生效(运行source 或者重新登陆)。

(4)

#cd /home/aceuser/ace/ACE_wrappers/ace/
#cp ./config-linux.h ./config.h
#cd ../include/makeinclude/
#ln -s ./platform_linux.GNU ./platform_macros.GNU

(5)编译
#cd /home/aceuser/ace/ACE_wrappers/
创建一个目录:
#mkdir build
#cd build
#../configure && make && make install

对于ACE-5.4+TAO-1.4+CIAO-0.4这个版本,不能ACE-5.4+TAO-1.4+CIAO-0.4.zip这个压缩包,否则会出现如下错误:
ln -s libACE.so.5.4.0 libACE.so
chmod a+rx libACE.so.5.4.0
: command not foundpers/bin/ace_components: line 10
'/home/aceuser/ace/ACE_wrappers/bin/ace_components: line 31: syntax error near unexpected token 'in
'/home/aceuser/ace/ACE_wrappers/bin/ace_components: line 31: ' case $1 in
make[1]: ***[ACE_COMONENTS] Error 2
make[1]: Leaving directory '/home/aceuser/ace/ACE_wrappers/ace'
make: ***[all] Error 2
如果换成ACE-5.4+TAO-1.4+CIAO-0.4.tar.gz就没有任何问题了

编译时也可以根据自己的需要设置编译选项
#make [options]
下面是option的描述:
Option Description
debug=1|0 Enable or disable debugging in the built library or program. Default is enabled (1).
optimize=1|0 Turn compiler optimization on or off. Default is off (0).
buildbits=bits Explicitly select, for example, 32-bit or 64-bit build target. Default is the compiler's default for the build machine. This option works for AIX, Solaris, and HP-UX.
exceptions=1|0 Enable or disable exception handling. Default is platform specific but usually enabled (1).
inline=1|0 Enable or disable inlining of many of ACE's methods. Default is platform specific but usually enabled (1).
templates=model Specify how templates are instantiated. Most common values for model are automatic, the default for compilers that support it well, and explicit, requiring source code directives to explicitly instantiate needed templates (see Section 1.6.1).
static_libs=1|0 Build and use static libraries. Default is to not build static libraries (0).

2.使用
下面介绍如何从零开始建立一个使用ACE的工程。并使之run起来

(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
如果程序没有任何问题,现在程序应该就可以运行了。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值