ACE在Linux 编译

来源:互联网 发布:我的世界无限耐久js 编辑:程序博客网 时间:2024/05/15 08:09

    

在Linux平台编译ACE,我使用的事ACE6.0,没有使用TAO,CIAO。

主要步骤如下:

一.设置环境变量

使用root账号登录,vi 打开/etc/profile文件(对所有用户生效),或者vi /home/运行账号/.bash_profile文件(对运行账号生效),在文件末尾添加:

ACE_ROOT=/soft/ACE_wrappers (根据实际路径修改)

export ACE_ROOT   LD_LIBRARY_PATH=$ACE_ROOT/ace:$ACE_ROOT/lib:/usr/local/lib:$LD_LIBRARY_PATH

export LD_LIBRARY_PATH

保存退出,退出重登录生效。

二. 查看你的autoconf程序的版本,如果低于2.65,到http://www.gnu.org/software/autoconf/下载最新版本的autoconf程序。编译并安装升级autoconf程序

1.           上传源码包

2.           解压ACE源码包。

3.           tar –xvf ACE.tar –C/soft/ACE_wrappers (路径与环境变量中ACE_ROOT有关)

4.           $ACE_ROOT/ace/,创建一个名为config.h的文件,在其中加入一行

                #include “ace/config-linux.h”

     或者,建立一个指向config-linux.h的符号连接

     ln –s config-linux.hconfig.h

5.       进入$ACE_ROOT/include/makeinclude目录中创建一个名为platform_macros.GNU的文件,在其中加入一行:

include $(ACE_ROOT)/include/makeinclude/platform_linux.GUN

或者,建立一个指向platform_linux.GNU的符号连接

 ln –s platform_linux.GNUplatform_marcros.GUN

6.           网络字节对齐定义

ACE网络字节默认使用整数字节对齐,很多时间,网络协议并不要求字节对齐,所以需要设置为不自动对齐,打开头文件$ACE_ROOT/ace/config.h,加入以下几行。

#define ACE_CDR_IGNORE_ALIGNMENT

#ifdef ACE_DISABLE_SWAP_ON_READ

#undef ACE_DISABLE_SWAP_ON_READ

#endif

#define ACE_LACKS_CDR_ALIGNMENT

#define ACE_ENABLE_SWAP_ON_WRITE

7.           同时在$ACE_ROOT/ace/config.h后面添加ACE_DEFAULT_THREAD_KEYS的宏定义,解决ACE_TSS 在线程数太多时程序崩溃的BUG

#defineACE_DEFAULT_THREAD_KEYS 1088

8.           ACE_DEV_POLL_REACTOR配置

Linux 平台上,ACE使用ACE_Dev_Poll_Reactor效率会有很大提高,要启用epoll模式,首先使用ulimit –n 5120修改open files;为使下次登录同样有效,还需要修改文件/etc/security/limits.conf文件,添加以下两行:

soft nofile 5120

hard nofile 10240

修改$ACE_ROOT/ace/config-linux.h,添加以下一行:

#define ACE_HAS_EVENT_POLL

9.           编译安装

cd 进入$ACE_ROOT/build目录,执行

../configure (注意,是两点,ACE的BUG,不能直接在上级目录下执行,会出错)

make

make install.

10.       如果make 是提示缺少依赖库的等,根据提示安装相应包,我服务器是Redhat as5的,可以使用yum 安装,现将我的yum配置文件附上:

 [main]

cachedir=/var/cache/yum

keepcache=1

debuglevel=2

logfile=/var/log/yum.log

pkgpolicy=newest

distroverpkg=redhat-release

tolerant=1

exactarch=1

obsoletes=1

gpgcheck=1

plugins=1

metadata_expire=1800

# PUT YOUR REPOS HERE OR IN separate files namedfile.repo

# in /etc/yum.repos.d

[base]

name=centos-5 - Base

baseurl=http://centos.ustc.edu.cn/centos/5/os/x86_64/

# the other site:http://centos.candishosting.com.cn/centos/5/os/x86_64/

# you can find more site in:http://www.centos.org/modules/tinycontent/index.php?id=13

enabled=1

gpgcheck=1

gpgkey=http://centos.ustc.edu.cn/centos/5/os/x86_64/RPM-GPG-KEY-CentOS-5

#released updates

[update]

name=CentOS-5 - Updates

baseurl=http://mirror.centos.org/centos/5/updates/x86_64/

gpgcheck=1

gpgkey=http://centos.ustc.edu.cn/centos/5/os/x86_64/RPM-GPG-KEY-CentOS-5

#packages used/produced in the build but not released

[addons]

name=CentOS-5 - Addons

baseurl=http://mirror.centos.org/centos/5/addons/$basearch/

gpgcheck=1

gpgkey=http://centos.ustc.edu.cn/centos/5/os/x86_64/RPM-GPG-KEY-CentOS-5

#additional packages that may be useful

[extras]

name=CentOS-5 - Extras

baseurl=http://mirror.centos.org/centos/5/extras/$basearch/

gpgcheck=1

gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4

#additional packages that extend functionality ofexisting packages

[centosplus]

name=CentOS-5 - Plus

baseurl=http://mirror.centos.org/centos/5/centosplus/$basearch/

gpgcheck=1

enabled=0

gpgkey=http://centos.ustc.edu.cn/centos/5/os/x86_64/RPM-GPG-KEY-CentOS-5

#contrib - packages by Centos Users

[contrib]

name=CentOS-5 - Contrib

baseurl=http://mirror.centos.org/centos/5/contrib/$basearch/

gpgcheck=1

enabled=0

gpgkey=http://centos.ustc.edu.cn/centos/5/os/x86_64/RPM-GPG-KEY-CentOS-5

#packages in testing

[testing]

name=CentOS-5 - Testing

baseurl=http://mirror.centos.org/centos/5/testing/$basearch/

gpgcheck=1

enabled=0

gpgkey=http://centos.ustc.edu.cn/centos/5/os/x86_64/RPM-GPG-KEY-CentOS-5

 

 

 

原创粉丝点击