ace在linux下编译

来源:互联网 发布:saber软件芯片tl494 编辑:程序博客网 时间:2024/05/22 12:53
ACE-6.4.0 linux下编译与安装
1. 从 http://www.cs.wustl.edu/~schmidt/ACE.html 的 Obtainin ACE 链接处下载ACE源码,我下载的是ACE-6.4.0.tar.gz
2. 假设下载的目录为~/source/ace
3. 解压ACE源码 tar zxvf ACE-6.4.0.tar.gz,解压后发现ace源码解压到~/source/ace/ACE_wrappers目录下
4. 参考http://www.dre.vanderbilt.edu/~schmidt/DOC_ROOT/ACE/ACE-INSTALL.html#unix   在linux环境下对ACE进行编译
4.1 设置环境变量
vim ~/.bash_profile
export ACE_ROOT=/home/yourname/ACE_wrappers

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

然后执行source ~/.bash_profile

4.2 创建文件 $ACE_ROOT/ace/config.h,写入如下内容
#ifndef _CONFIG_H_
#define _CONFIG_H_
#include "ace/config-linux.h"
#endif
4.3 创建platform_macros.GNU
方法一:创建文件 $ACE_ROOT/include/makeinclude/platform_macros.GNU 写入
include $(ACE_ROOT)/include/makeinclude/platform_linux.GNU
方法二:利用软连接创建
ln -s  $ACE_ROOT/include/makeinclude/platform_macros.GNU $ACE_ROOT/include/makeinclude/platform_linux.GNU

可以在platform_macros.GNU写入INSTALL_PREFIX=/usr/local,将ace的include lib share安装到/usr/local目录下

4.4 make
4.5 切换到root,因为只有root才可以写文件到/usr/local,并设置环境变量
    su root
    export ACE_ROOT=/home/yourname/ACE_wrappers
    make install

    切换到/usr/local,进入include lib share可以看到ace的相关文件

4.6 上面使用$ACE_ROOT/lib作为ace的库文件路径,因为后面我们安装到/usr/local/lib里,可以把/usr/local/lib加入默认库文件查找路径
打开/etc/ld.so.conf
本来内容是如下:
include ld.so.conf.d/*.conf
我们添加ace路径后变成如下
include ld.so.conf.d/*.conf
/usr/local/lib
保存退出!
然后执行   ldconfig就可以了。

5. 测试

下面我们弄一个简单的ace程序:
/root/hello.cpp:
#include "ace/OS.h"
#include "ace/Log_Msg.h"
int main (int argc, char *argv[])
{
ACE_DEBUG((LM_DEBUG,"Hello, ACE!\n "));
ACE_OS::exit(1);
return 0;
}
这么就不写makefile了,直接用g++编译就是了。
编译
g++ hello.cpp -o hello -lACE
运行:
./hello
运行,输出了Hello, ACE! 哈哈~got it!

6. 参考:
   《ACE-6.1.0 linux 下的编译与安装步骤》http://www.cnblogs.com/liangxiaxu/archive/2013/03/07/2948417.html

   官方网站写的编译方法:http://www.dre.vanderbilt.edu/~schmidt/DOC_ROOT/ACE/ACE-INSTALL.html#unix  

   《ACE在Linux 和 Windows 下ACE的编译》http://blog.csdn.net/zklth/article/details/7190927

    
1 0