ACE安装

77 篇文章 1 订阅
54 篇文章 1 订阅

官网:http://www.dre.vanderbilt.edu/~schmidt/ACE.html

ACE的安装文档请看源码根目录下的 ACE-INSTALL.html 文件。

 用mpc产生适应你需要的编译配置。例如用automake编译

bin/mwc.pl -type automake ACE.mwc

Using .../root/ACE_wrappers/bin/MakeProjectCreator/config/MPC.cfg
CIAO_ROOT was used in the configuration file, but was not defined.
DANCE_ROOT was used in the configuration file, but was not defined.

这个错误不用管,它是编译CIAO和DANCE时需要的,只要在环境变量中配置这两个变量就可以了。

 

例如生成在vc2010下编译配置:

bin/mwc.pl -type vc10 ACE.mwc

 

 

ACE在Linux环境下的编译安装
            

第一步 设置ACE_ROOT环境变量
(1)export ACE_ROOT=/home/jet/ACE_wrappers
export LD_LIBRARY_PATH=$ACE_ROOT/ace:$LD_LIBRARY_PATH

(2)或者直接在用户目录下编辑.bashrc文件,内容如下:
ACE_ROOT=/home/jet/ACE_wrappers
export ACE_ROOT
LD_LIBRARY_PATH=$ACE_ROOT/ace:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH
然后重新登陆

(3)另一种方法是修改系统的/etc/profile文件(不过这样还是以用户变量为
优先设置,即如果已经按照上面的两种方法进行了设置,那么以下的设置将不
会被系统采用。)
“vi /etc/profile”
在其中加入4行
ACE_ROOT=/opt/ACE
export ACE_ROOT
LD_LIBRARY_PATH=$ACE_ROOT/ace:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH
我是加在“export PATH USER….”后的。完成后将/etc/profile执行一次,命令:
“chmod 555 /etc/profile”
“/etc/profile”
这样我们的ACE_ROOT就设置好了,可以用如下命令查看ACE_ROOT是否设置好了:
“echo $ACE_ROOT”
这个时候最好reboot启动一次linux。
-------------------------------------------------------------------

第二步 解压出ACE-install.sh文件并修改
(1)在/home/jet下建立子目录ACEInstall,将ACE.tar.gz上传至该目录

(2)从ACE.tar.gz解压出单个文件ACE-install.sh:
tar –zxvf ACE.tar.gz ACE_wrappers/ACE-install.sh

(3)ACE-install.sh放在哪个目录下无所谓,因为安装目录是由刚才设定的$ACE_ROOT决定的。

(4)vi ACE-install.sh
我们可以看到缺省的,这个文件是用来在UNIX下做安装的。所以我们要将其中的有
关UNIX的部分换成linux即可。
“MY_ACEDIR=${HOME}/aceconfig” -->> “MY_ACEDIR=/home/my/ACE”
“MY_ACE_CONFIG=config-sunos5.4-sunc++-4.x.h” -->> “MY_ACE_CONFIG=config-linux.h”
“MY_ACE_GNU_MACROS=platform_sunos5_sunc++.GNU” -->> “MY_ACE_GNU_MACROS=platform_linux.GNU”
好了,文件修改完毕,保存退出“:wq”。
-------------------------------------------------------------------

第三步 运行ACE-install.sh(shell脚本)安装ACE
(1)当前目录/home/jet/ACEInstall/ACE_wrappers

(2)修改ACE-install.sh的属性,使其可执行
chmod 777 ACE-install.sh

(3)执行:
./ACE-install.sh
此后将是较长时间的解包、编译等待时间。这个过程将不会出现任何错误,因为安装脚本
将为我们做很多事情,如:生成config.h,生成platform_macros.GNU。(即使出现删除
文件的错误,对结果应该没有影响,遇到这种情况要具体分析一下。)
因此就不需要按ACE-install.html中说的那样手工做如下改动:
  在$ACE_ROOT/ace目录下:
  ln -s config-linux.h config.h
  在$ACE_ROOT/include/makeinclude/目录下:
  ln -s platform_linux.GNU platform_macros.GNU
(Windows中没有文件连接这一说,所以要自己生成一个config.h文件,再在它的里面加一
句话“#include "ace/config-win32.h"”。)

(4)如果编译中出现错误,如“../apps/gperf”等,请编辑$ACE_ROOT/apps下的Makefile,
将其中的有关“gperf”的部分注释掉,这个东西只是一个例子,可以不去编译它。
强调一下,用ACE-install.sh来安装,会编译ACE、tests、apps等。
最后会生成libACE.so及tests、apps下也会出来很多经过编译的文件。
当然如果你只是下载了ACE.tar.gz这样的单个包来安装,你可以手工改文件,再make,
因为只编译ACE,工作就少了很多,手工做还可以接受。

(5)编译过程日志放在/tmp/myacemaker.err
-------------------------------------------------------------------

第四步 直接测试ACE提供的例子
(1)在$ACE_ROOT/examples/Synch中,修改proc_sema.cpp文件如下:
#include "ace/OS_NS_stdio.h"
在main函数中
ACE_OS::printf("Hello,World! /n");

(2)执行make,OK后运行。

(3)如果运行时装在不到share object,可能是lib路径问题,因为.so文件是程序运行过程中
装载的,不是在编译的时候,因此要设置LD_LIBRARY_PATH:
[jet@S]$ export LD_LIBRARY_PATH=/home/jet/ACE_wrappers/lib:$LD_LIBRARY_PATH
-------------------------------------------------------------------

第五步 写一个简单的程序测试一下ACE
(1)在/home/jet/下新建ACETest子目录,写好程序如client.cpp,上传到该目录

(2)拷贝第四步的那个Makefile文件到该目录,并做如下修改
修改其中输出文件名“BIN = hello”,并修改“
.obj/proc_sema.o .obj/proc_sema.so .shobj/proc_sema.o .shobj/proc_sema.so: proc_sema.cpp /”
中后面的“proc_sema.cpp”成“client.cpp”。
好,我们可以编译一个我们自己的ACE程序了,make即可。应该能通过,生成执行文件client,
大小大约为112Kb。运行之,“./client”。
-------------------------------------------------------------------

=================================================
另一种更为直接的安装方法:

步骤1:设置环境变量
export ACE_ROOT=/home/jet/ACE_wrappers
export LD_LIBRARY_PATH=$ACE_ROOT/ace:$LD_LIBRARY_PATH
也可以直接修改.bashrc文件,以免退出后设置的这些变量消失

[env][echo $ACE_ROOT]

步骤2:
针对不同版本创建两个文件链接:
  在$ACE_ROOT/ace目录下:
  ln -s config-linux.h config.h
  在$ACE_ROOT/include/makeinclude/目录下:
  ln -s platform_linux.GNU platform_macros.GNU

步骤3:
在$ACE_ROOT目录下,新建一个目录,用以执行configure的结果
  mkdir aaa
  cd aaa
在$ACE_ROOT/aaa中运行
  ../configure
在确认结果无误后,执行
  make
OK!

 

[rm -f -r *]删除目录下所有的文件和子目录-f是强制force删除,-r是代表目录也删除

[ldd 可执行文件] 显示该文件运行时候需要的动态链接库

[ipcs] 显示系统的共享内存、信号量、消息队列的情况 ipc show
[ipcrm <shm| msg| sem> id]

 

 建议按下面方法做:

一、下载安装包

下载地址:http://download.dre.vanderbilt.edu/

由于我只需要使用ACE,因此我只下载了ACE.tar.gz

二、安装前的配置

 

首先把文件解压,我解压在了/Software文件夹下,解压后会出现一个名字为ACE_wrappers的文件夹。这样所有ACE的源文件都在/Software/ACE_wrappers里面

配置环境变量:

# vi /etc/profile

增加如下的内容

ACE_ROOT=/Software/ACE_wrappers      ------就是上面存放ACE源文件的目录

export ACE_ROOT

LD_LIBARY_PATH=$ACE_ROOT/ace:$LD_LIBARY_PATH

export LD_LIBARY_PATH

# source /etc/profile

三、开始安装ACE

# cd /Software/ACE_wrappers

# vi ace/config.h

增加如下信息:

#include “ace/config-linux.h”

如果想用MSVC标准C++头,则需要在ace/config.h中增加定义:

#define ACE_HAS_STANDARD_CPP_LIBARY 1

我的config.h文件内容如下:

#define ACE_HAS_STANDARD_CPP_LIBARY 1     //  使用标准C++头

#define ACE_NO_INLINE     //  不使用内连函数,能减小LIB和EXE的大小

#include “ace/config-linux.h”

保存后退出

# mkdir build   ----新建一个build文件夹

# cd build

# ../configure --prefix=/usr/local/ACE         -------在这里我指定了ACE的安装路径

# make & install

可以去泡杯咖啡慢慢等

四、配置ACE环境

# vi /etc/ld.so.conf.d/ace.conf

在文件中增加如下信息:

/usr/local/ACE/lib

# ldconfig

五、测试ACE环境是否安装配置成功

编写一个简单的ACE程序,在这里我就用最简单的Hello World了,代码如下:

#include <ace/Log_Msg.h>

#include <ace/OS_main.h>

using namespace std;

int ACE_TMAIN(int argc, ACE_TCHAR *argv[])

{

ACE_DEBUG((LM_DEBUG, ACE_TEXT(“Hello World!”)));

return 0;

}

编译:

# g++ -I/usr/local/ACE/include -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"HelloWorld.d" -MT"HelloWorld.d" -o"HelloWorld.o" "HelloWorld.cpp"

链接:

# g++ -I$ACE_ROOT -L/usr/local/ACE/lib -o"ACETest" ./HelloWorld.o -lACE -lrt –lpthread

注意:在链接的时候,必须要加-lACE –lrt -lpthread三个参数,否则会报错。

执行:

# ./ACETest

成功执行的话,会打印出Hello World


 在64位系统上编译32位库
linux32 ../configure --with-tao=no --enable-ssl=no --prefix=/home/sxit/kl/ACE_wrappers/build --enable-ace-examples=no --enable-ace-tests=no --enable-ace-cdr-swap-on-read=no --enable-reentrant=no --enable-ace-cdr-alignment=no CCFLAGS="-m32 " CPPFLAGS="-m32 " CXXFLAGS="-m32" CFLAGS="-m32"

linux32 ../configure --prefix=/home/sxit/kl/ACE_wrappers/build --with-tao=no --enable-ssl=no --enable-ace-examples=no --enable-ace-tests=no CCFLAGS="-m32 " CPPFLAGS="-m32 " CXXFLAGS="-m32" CFLAGS="-m32"

../configure --with-tao=no --enable-ssl=no --prefix=/home/sxit/kl/ACE_wrappers/build --exec-prefix=/home/sxit/kl/ACE_wrappers/build/lib64 --enable-ace-examples=no --enable-ace-tests=no --enable-ace-cdr-swap-on-read=no --enable-reentrant=no --enable-ace-cdr-alignment=no                                        

linux32 ../configure CCFLAGS="-m32 " CPPFLAGS="-m32 " CXXFLAGS="-m32" CFLAGS="-m32"

 

 

 

 

Makefile Flags

GNU make provides many options to customize its operation. See its documentation for more information. One example is that for multi-cpu UNIX machines you will be able to build faster if you use:


% make -j n

which allows parallel compilation. The number n should typically be the number of CPUs. It is likely that builds will be faster even on single-CPU UNIX machines withmake -j 2.

ACE further supports the following flags. They can be enabled either on the command line, e.g., "make purify=1", or added to yourplatform_macros.GNU. To disable the option, set the flag to null, e.g., "make debug=". Some flags support setting to 0 disable, e.g., "make debug=0". debug=1 is enabled in the platform files that are released with ACE.

Please note that the effects of a flag may be platform specific. Also, combinations of certain flags may or may not be allowed on specific platforms, e.g., debug=1 opt=1 is supported by g++ but not all other C++ compilers.

If you use Purify or Quantify: purify or quantify must be on yourPATH. By default, ACE puts the Purify/Quantify caches below /tmp. To override that, set thePURE_CACHE_BASE_DIR variable, either in your environment or on the make make command line, to the destination directory for your instrumented libraries.

Flag             Description
----             -----------
debug            Enable debugging; see DCFLAGS and DCCFLAGS.
exceptions       Enable exception handling (not supported by all platforms).
include_env      Support old-style ACE_TRY_ENV declarations in methods.
                 This switch is necessary for compiling TAO applications
                 in the native exception configuration that were written
                 for TAO versions before 1.2.2.
                 In TAO 1.2.2, new macros were introduced that supercede
                 the direct ACE_TRY_ENV declarations. These are the
                 ACE_ENV_ARG macros that are defined in ace/CORBA_macros.h
                 and are documented in docs/exceptions.html.
                 This switch only affects the exceptions=1 configuration.
                 It is for backward compatibility only.
                 There will be warnings about unused _ACE_environment_variable
                 parameters when using include_env=1.
                 If possible, do not use it, but instead change your TAO
                 applications to use the ACE_ENV_ARG macros.
fast             Enable -fast option, e.g., with Sun C++.
inline           Enable ACE inlining.  Some platforms enable inlining by
                   default, others do not.
optimize         Enable optimization; see OCFLAGS and OCCFLAGS.
pace             Enable PACE as the underpinnings of ACE_OS.
probe            Enable ACE_Timeprobes.
profile          Enable profiling; see PCFLAGS and PCCFLAGS.
purify           Purify all executables.
quantify         Quantify all executables.
repo             Use GNU template repository (g++ with repo patches only).
rtti             Enable run-time type identification.  On some platforms,
                   it is enabled by default, so this is ignored.
shared_libs      If migrating from prior version use shared_libs_only
static_libs      If migrating from prior version use static_libs_only
shared_libs_only Only build shared libraries.  Ignored if no SHLIBs are
                   specified by the Makefile, as in performance-tests/Misc.
static_libs_only Only build static libraries.
threads          Build with thread support.
xt               Build with Xt (X11 Toolkit) support.
fl               Build with FlTk (Fast Light Toolkit) support.
tk               Build with Tk (Tcl/Tk) support.
qt               Build with Qt (Trolltech Qt) support.
ssl              Build with OpenSSL support.
rapi             Build with RAPI
split            Build the library by first splitting up the ACE source
                   to several files, with one object code entity for each
                   source file. This allows an application that is linked
                   with ACE to extract _exactly_ what it needs from the
                   library, resulting in a smaller executable.  Setting this
                   to 1 overrides debug to 0.

Usually, users do not need to be concerned with make targets.
Just enter "make" on the command line to build.  A few notable
targets are listed below.

Target             Description
------             -----------
show_statics       Lists all static objects in object files built for
                     current directory.  Only supported for g++.
show_uninit        Lists all uninitialized in object files built for
                     current directory.  Only supported for g++.

http://www.dre.vanderbilt.edu/~schmidt/DOC_ROOT/ACE/ACE-INSTALL.html#installnotes

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值