ACE、TAO、CIAO


1.1.1 ACE

ACE 自適配通信環境(ADAPTIVE Communication Environment)是可自由使用、開放源碼的面向對象(OO)框架(framework) ,它實現了許多用於併發通信軟件的核心模式。

ACE 提供了一組豐富的可重用 C++包裝外觀(wrapper facade)和框架組件,可跨多種平臺完成通用的通信軟件任務,其中包括:事件多路分離和事件處理器分派、信號處理、服務初始化、進程間通信、共享內存管理、消息路由、分佈式服務動態(重)配置、併發執行和同步,等等。

ACE 的目標用戶是高性能和實時通信服務和應用的開發者。它簡化了使用進程間通信、事件多路分離、顯式動態鏈接和併發的 OO網絡應用和服務的開發。此外,通過服務在運行時與應用的動態鏈接,ACE 使系統的配置和重配置得以自動化。

1.1.2 TAO

The ACE ORB(TAO) :TAO 是使用 ACE 提供的框架組件和模式構建的 CORBA 實時實現,包含有網絡接口、OS、通信協議和 CORBA 中間件組件及特性。TAO 基於標準的 OMG CORBA 參考模型,並進行了增強的設計,以克服傳統的用於高性能和實時應用的 ORB 的缺點。TAO像 ACE 一樣,也是可自由使用的開放源碼軟件。

1.1.3 CIAO

CIAO(Component Integrated ACE ORB)則是在TAO基礎上的一個CORBA Component Model實現,同時CIAO也是目前相對比較成熟的一個CCM實現。

1.  下載 ACE 5.7.
從 http://download.dre.vanderbilt.edu/ 下載 ACE+TAO+CIAO-5.7.tar.gz包。

2.  解壓
將壓縮包copy到linux目錄/data/ACE裏,然後解壓, tar -zxvf ACE+TAO+CIAO-5.7.tar.gz。
解壓後的目錄是 /data/ACE_wrappers.

3.  配置config.h和platform_macros.GNU。
官方文檔上是這麼寫的:
Create a configuration file, $ACE_ROOT/ace/config.h, that includes the appropriate platform/compiler-specific header configurations from the ACE source directory. For example: 
#include "ace/config-linux.h"

Create a build configuration file, $ACE_ROOT/include/makeinclude/platform_macros.GNU, that contains the appropriate platform/compiler-specific Makefile configurations, e.g., 
include $(ACE_ROOT)/include/makeinclude/platform_linux.GNU

在實際操作中也可以直接創建一個軟鏈接:
cd $ACE_ROOT/ace 
ln -s config-linux.h config.h
cd $(ACE_ROOT)/include/makeinclude/
ln -s platform_linux.GNU platform_macros.GNU


3.  configure
    cd ACE_wrappers/
    mkdir build
    ../configure
    等幾分鐘後configure完成。

4.  make
    在ACE_wrappers/build目錄下, 執行$make 
    make完以後,在/data/ACE/ACE_wrappers/build/ace/.libs/目錄下,能找到libACE.so和libACE-5.7.so.
    
    make特別慢,尤其是ACE+TAO+CIAO在一起的這個包,make要好幾個小時。如果TAO和CIAO用不着的話,只下載ACE的就可以了,可以省點時間。 

5.  install
    在ACE_wrappers/build下執行#make install
    make install之後,會在/usr/local/include下找到好幾個ace相關的文件夾,裏面有include需要的頭文件。
    在/usr/local/lib下找到一堆ACE相關的.so文件,包括libACE.so等等。
    
    linux下系統查找include文件的順序是(這段是網上摘抄的):
    /usr/include
    /usr/local/include
    /usr/lib/gcc-lib/i386-linux/2.95.2/include
    /usr/lib/gcc-lib/i386-linux/2.95.2/../../../../include
    /usr/lib/gcc-lib/i386-linux/2.95.2/../../../../i386-linux/include
    查找lib文件的順序是
    /lib
    /usr/lib
    而ACE的lib所在的目錄是 /usr/local/lib,所以要注意爲lib配置環境變量。

6.  配置環境變量
    配置.bashrc
    ~/.bashrc:
    ACE_ROOT=/home/cs/faculty/schmidt/ACE_wrappers; export ACE_ROOT 
    LD_LIBRARY_PATH=$ACE_ROOT/lib:$LD_LIBRARY_PATH;export LD_LIBRARY_PATH
    配置完環境變量執行以下 . ~/.bashrc
    或者註銷重新登錄一下。

    配置ld.so.conf
    打開/etc/ld.so.conf
    本來內容是如下:
    include ld.so.conf.d/*.conf
    我們添加ace路徑後變成如下
    include ld.so.conf.d/*.conf
    /usr/local/lib
    保存退出
    然後執行    ldconfig

7  用gcc測試一下。
   寫小程序:

hello.cpp

#include "ace/OS.h"
#include "ace/Log_Msg.h"
int main (int argc, char *argv[])
{
ACE_DEBUG((LM_DEBUG,"Hello, ACE! "));
ACE_OS::exit(1);
return 0;
}

編譯:
[root@linuxvm1 test]# gcc -p -o hello hello.cpp -I /data/ACE/ACE_wrappers -L /data/ACE/test/ -l ACE -lz -lm
編譯的時候-l要寫ACE,而不是libACE.so
執行:
[root@linuxvm1 test]# ./hello
./hello: error while loading shared libraries: libACE-5.7.so: cannot open shared object file: No such file or directory
[root@linuxvm1 test]# export LD_LIBRARY_PATH=/data/ACE/test
[root@linuxvm1 test]# ./hello
Hello,ACE!


8  用KDevelop測試一下。
把/data/ACE/ACE_wrappers/examples/C++NPv1裏面的 Iteractive_Logging_Server(Iteractive_Logging_Server.cpp, Iteractive_Logging_Server.h,Logging_Handler.cpp,Logging_Handler.h,Logging_Server.cpp,Logging_Server.h) 和Logging_Client(Logging_Client.cpp)兩個project加到KDevelop裏面。
然後配置一下用到的lib:在Project Options->Configure Options -> General->Linker flags(LDFLAGS)中添加 /usr/local/lib/libACE.so.
然後build。
執行#./iteractive_logging_server 9999
執行#./logging_client 9999

執行成功。

ace

9. eclipse中配置:
   Project -> Properties -> C/C++ Build -> Settings -> Tool Settings -> GCC C++ Linker -> Libraries
   Libraries(-l)添加:ACE
   Library search path(-L)添加: /usr/local/lib/

10.在VS2005上創建工程的問題。
主要是要在工程屬性裏做一下配置,具體配置就參考自帶的那些例子裏面的工程的配置就可以了。
隨便打開一個工程,挨個對一下上面的配置,就可以跑了。


注:有時候會報undefined reference to的錯誤,可能是.so文件沒有找到。比如這種情況。
[root@linuxvm1 test]# gcc -p -o hello hello.cpp -I /data/ACE/ACE_wrappers -L /data/ACE/test/libACE.so -lz -lm
/tmp/ccPse7FN.o(.text+0x22): In function `main':
: undefined reference to `ACE_Log_Msg::last_error_adapter()'
/tmp/ccPse7FN.o(.text+0x2a): In function `main':
: undefined reference to `ACE_Log_Msg::instance()'
/tmp/ccPse7FN.o(.text+0x44): In function `main':
: undefined reference to `ACE_Log_Msg::conditional_set(char const*, int, int, int)'
/tmp/ccPse7FN.o(.text+0x59): In function `main':
: undefined reference to `ACE_Log_Msg::log(ACE_Log_Priority, char const*, ...)'
/tmp/ccPse7FN.o(.text+0x66): In function `main':
: undefined reference to `ACE_OS::exit(int)'
/tmp/ccPse7FN.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章