ACEのコンパイルとインストール、for windows、Linux

14588 ワード

一.Windowsでのfor MSVCのインストールと構成
http://download.dre.vanderbilt.edu/ダウンロード
ACE-5.4+TAO-1.4+CIAO-0.4を使用しています.zip、Windowsで圧縮パッケージをターゲットパスに解凍します(D:ACE_wrappersとします)、
ファイルの作成:$ACE_ROOT/ace/config.h,1行追加:#include"ace/config-win 32.h"
Windows 9 x/Meの場合は$ACE_ROOT/ace/config.h中#include文の前に:#define ACE_を加えるHAS_WINNT4 0
Standard C++headerを使用するには$ACE_ROOT/ace/config.h中#include文の前に:#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の#include文の前に、#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を実現できる.
最初の4つのdllはD:ACE_にありますWRAPPERSbinディレクトリの下で、すべて対応しています.libライブラリファイルはD:ACE_WRAPPERSaceの下.
ACEはネットワーク通信ミドルウェアで、マシンにNICが装着されていない場合は、コントロールパネルからMS Loopback Adapterを選択できるなど、シミュレーションを行います.
次に、マシンに異なるバージョンのACEがインストールされている場合、あるバージョンに対して構成する必要がある新しいプロジェクトを作成します.方法は次のとおりです.
1.C/C++tabの構成
(1)Code Generation categoryでは適切なオプションを選択する必要があります:MultithreadedとMultithreaded DLLはfor Release版のDebug MultihreadedとDebug Multithreaded DLLはfor Debug版の
(2)$(ACE_ROOT)パスの構成:異なるバージョンのACEに対して柔軟な構成が必要な場合は、D:ACE_などの特定のバージョンのACEが存在するパスを示すPreprocessor categoryの「Additional include directories」を設定する必要があります.wrappers
2.特定バージョンのACEライブラリにリンクします.
(1)D:ACE_wrappersace、D:ACE_wrappersbinディレクトリの下の対応するdllをプロジェクトファイルのあるパスにコピーするか、環境変数PATHにD:ACE_を追加します.wrappers\bin.
(2)Project/Setting/LinkのInput categoryの「Object/library modules」に含めるACEライブラリを指定します(*.lib)
ACEが1つしかインストールされていない場合は、次の方法で、すべてのプロジェクトに対して有効なデフォルト構成を使用できます.
1.環境変数の追加:ACE_ROOT:  D:\ACE_wrappersPATHに追加:D:ACE_wrappers\bin
2.VSのパスの設定:Include files含む:D:ACE_wrapperslibrary 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は次の2行を追加します: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/ディレクトリの作成:#mkdir build#cd build#../configure && make && make install
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/bin/ace_components: line 10  '/home/aceuser/ace/ACE_wrappers/bin/ace_components: line 31: syntax error near unexpected token 'in  '/home/aceuser/ace/ACE_wrappers/bin/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 Enableor 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の作成
 


コード#コード#

   
     
BIN = hello_ace
FILES
= Piece2 Piece3
SRC
= $(addsuffix .cpp,$(FILES))
OBJ
= $(addsuffix .o,$(FILES))
BUILD
= $(VBIN)
#
---------------------------------------------------------
# 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とPiece 3.cpp
(3)コンパイル#makeプログラムに問題がなければ,プログラムを実行できるはずである.
 
(4)よくあるエラー1:「Cannot open include file:ace/SOCK_Acceptor.h:No such file or directory」解決方法:Project->settings->C/C+:PreprocessorのAdditional include directoriesに$ACEを加えるROOT、例えばE:/ACE_wrappersエラー2:「You must link against multi-threaded libraries when using ACE(check your project settings)」解決策:Project->settings->C/C+:Code GenerationのUse run-time library:Debug Multihreaded Dllエラー3:「error C 2065:ACE_ERROR:undeclared identifier」"error C 2065:ACE_DEBUG:undeclared identifier"解決方法:原馬に#i nclude ace/LOgを加えるMsg.hエラー4:「error C 4716:ace_main_i:must return a value」解決方法:mainにreturn 0を加える;エラー5:"error LNK 2001:unresolved external symbol__declspec(dllimport)int__cdecl"解決方法:Project->settings->Link->Input:Object/library Modulesがacedに参加する.lib,Additional Library Pathに$ACEを追加ROOTace、例えばE:ACE_wrappersaceコンパイルclientで発生した問題:エラー6:error C 2039:sprintf:is not a member of ACE_OS解決方法:#i nclude ace/OS_NS_stdio.hエラー7:error C 2039:strlen:is not a member of ACE_OS解決方法:#i nclude ace/OS_NS_string.hエラー8:ダイナミックリンクライブラリacedが見つかりません.dll指定されたパス解決方法:システム変数PATHにD:ACE_を追加wrappersbin静的包含:エンジニアリング-設定-C/C++-プリプロセッサ定義に追加,ACE_AS_STATIC_LIBS
 
 
 
 
 
これからハロースペースを書くことを勉強します. 
 


コード#コード#

   
     
// ---------------------------------------------------------------
// @file: hello.cpp

#include
< stdio.h >
#include
" ace/Log_Msg.h "
#include
" ace/OS_main.h "
int ACE_TMAIN( int argc, ACE_TCHAR * argv[])
{
ACE_DEBUG((LM_DEBUG,ACE_TEXT(
" hello world.
" )));
return 0 ;
}

//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------mpc
 

  
    
project(hello) :aceexe{
exename
= hello
after
+= hello

Source_Files {
hello.cpp
}
}

------------------------------------------------------------------MPCユーティリティでMakefileファイル$ACEを生成するROOT/bin/mwc.pl -type make hello.mpcはMakefileとMakefileを手に入れます.hello 2つのファイルmakeを実行すると実行可能ファイルhello./ハロー