ACE 安裝 絕對成功 轉載

轉載:http://hi.baidu.com/wfpb_1984/blog/item/23d80f5486a73356574e0037.html

當初我安裝ACE時,失敗了幾次,後來按照這個來,才完全成功。
如果大家有人使用VC助手的話,安裝完後打開VC編寫程序時,編譯器最下面VX會不停的加載頭文件,因爲它要達到能夠提示完成函數原形的功能,所以他要全部加載,但是每次都如此,會比較煩,你可以點擊VX的option裏設置一下directory,增加你的ace文件夾到裏面,這樣就OK了,終於可以爽爽的用了。

 

整理方法如下:

一. Windows下for MSVC的安裝與配置

我們用的是ACE-5.4+TAO-1.4+CIAO-0.4.zip,Windows下解壓縮該壓縮包到目標路徑(設爲D:/軟件安裝/編程學習軟件/ACE_wrappers ),

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

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

如果想使用standard C++ header,需要在$ACE_ROOT/ace/config.h中#i nclude語句前加入:
#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中#i nclude語句前加入:
#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/lib目錄下, 所有對應的.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/lib目錄下對應的dll拷貝到工程文件所在路徑下,或者在環境
變量PATH中加入D:/軟件安裝/編程學習軟件/ACE_wrappers/lib。

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


如果只裝了一個ACE,可採用對所有工程都生效的缺省配置,方法如下:

1. 添加環境變量:
ACE_ROOT:   D:/軟件安裝/編程學習軟件/ACE_wrappers
PATH 中加入:D:/軟件安裝/編程學習軟件/ACE_wrappers/lib

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/ace/
   #make
   對於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/lib/ace_components: line 10
   '/home/aceuser/ace/ACE_wrappers/lib/ace_components: line 31: syntax error near unexpected token 'in
   '/home/aceuser/ace/ACE_wrappers/lib/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

lib = hello_ace
FILES = Piece2 Piece3
SRC= $(addsuffix .cpp,$(FILES))
OBJ= $(addsuffix .o,$(FILES))
BUILD    = $(Vlib)
#---------------------------------------------------------
# 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
   如果程序沒有任何問題,現在程序應該就可以運行了。

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