好文档就是一把金锄头!
欢迎来到金锄头文库![会员中心]
电子文档交易市场
安卓APP | ios版本
电子文档交易市场
安卓APP | ios版本

ACE的编译和安装-网络编程.doc

9页
  • 卖家[上传人]:ss****gk
  • 文档编号:235968812
  • 上传时间:2022-01-06
  • 文档格式:DOC
  • 文档大小:141.50KB
  • / 9 举报 版权申诉 马上下载
  • 文本预览
  • 下载提示
  • 常见问题
    • ACE 的编译和安装,for windows、Linux一.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,增加一行:#include "ace/config-win32.hM如果是在 Windows 9x/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 intoACE),则需要在$ACE_ROOT/ace/config.h 中#include 语句前加入:#define ACE_HAS_MFC 1如果想牛成ACE静态库或在工程中使用ACE静态库,都需要定义以下宏:AC E_AS_STAT IC_LI BS打开工程,D:\ACE_wrappers\ace.dsw,编译生成以下库:匡曰代码ace ・dl1/ace・lib (DLL release)seed, dll/aced・2.ib (DLL debug)acemfc ・d丄1/acemfc•丄ib (MFC DLL release) acemfcd・d丄l/ecemfcd・lib (MFC DLL debug) aces•丄ib (Static library release)acesd•丄ib (Static library debug)这些库可分別实现了 Debug/Release, MFC/Non-MFC, Static/Dynamic library.其中前四个的dll在D:\ACE_WRAPPERS\bin目录下,所有对应的.lib库文件在D:\ACE_WRAPPERS\ace 下。

      ACE是网络通讯中间件,如果机器没有装网卡,就仿真一个,比如可以从控制面板选装MSLoopback 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_wrappers2. 链接到特定版本的ACE席1)在 Project/Setting/Link 的 Input category 下 nAdditional library path**中增加特定版木的ACE库文件路径,比如D:\ACE_wrappers\ace,然后将D:\ACE_wrappers\bin目录下对应的dll拷贝到工程文件所在路径下,或者在环境变量 PATH 中加入 D:\ACE_wrappers\birio(2)在 Project/Setting/Link 的 Input category FnObject/library modules"中指定需要 包含的ACE库(=lib)如果只装了一个ACE,可采用对所有工程都生效的缺省配置,方法如下:1. 添加环境变量:ACE_ROOT: D:\ACE_wrappersPATH 中加入:D:\ACE_wrappers\bin2. 设置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 /h o m e/ace use r/ace#tar -xzvf ACE-5.4+TA0-1.4-+-CIAO-0.4.tar.gz(3)#vi /home/aceuser/.bashrc加入下面两行:export ACE_ROOT=/home/aceuser/ace/ACE_wrappersexport 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 ./pla廿orm_linux・GNU ./pIatform_macros.GNU(3) 编译#cd /home/aceuser/ace/ACE_wrappers/创建一个目录:#mkdir build#cd build#../configure && make && make install对于 ACE-5.44-TAO-1.4+CIAO-0.4 这个版本,不能 ACE-5.4+TAO-1.4+CIAO・0.4.zip这个压缩包,否则会出现如下错误:In -s libACE.so.5.4.0 libACE.sochmod a+rx libACE.so.5.4.0:command not foundpers/bin/ace_components: line 107home/aceuser/ace/ACE_wrappers/bin/ace_components: line 31: syntax error near unexpected token fin7home/aceuser/ace/ACE_wrappers/bin/ace_components: line 31: 1 case $1 inmake[1]: ***[ACE_COMONENTS] Error 2make[1J: Leaving directory Vhome/aceuser/ace/ACE-Wrappers/ace1make: ***[all] Error 2如果换成ACE-5.4+TAO-1.4+CIAO・0.4.tar.gz就没有任何问题了编译时也可以根据自己的需要设置编译选项#make [options]下面是option的描述:Option Descripti ondebug=110 Enable or disable debugging in the built library or program. Default is enabled (1).optimize=110 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=110 Enable or disable exception handling. Default is platform specific but usually enabled (1).inline=110 Enable or disable inlining of many of ACEfs 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=110 Build and use static libraries. Default is to not build static libraries (0).2. 使用下面介绍如何从零开始建立一个使用ACE的工程。

      并使之run起来(1) 编写使用FACE的代码(2) 编写 Makefile田日代码BIN = hello_aceFILES = Piece2 Piece3SRC= $(addsuffix ・cpp,$(FILES))0BJ= $(addsuffix .oz $(FILES))BUILD = $ (VBIN)# # Include macros and targetsinclude $(ACE_ROOT)/include/makeinclude/wrapper_macros.GN uinclude $(ACE_ROOT)/include/makeinclude/macros•GNUinclude $(ACE_ROOT)/include/makeinclude/mon.GNU include $(ACE_ROOT)/include/makeinclude/rules•nonested.GN uinelude $(ACE_ROOT)/include/makeinclude/rules ・bin ・ GNU include $(ACE_ROOT)/include/makeinclude/rules•local•GNU以上的 Makefile 包含 3 个 epp 文件 hello_ace.cpp・ Piece2.cpp 和 Piece3.cpp(3) 编译#make如果程序没有任何问题,现在程序应该就可以运行了。

      4) 常见错误错误“Cannot open include file: ace/SOCK_Acceptor.h: No such file or directory”解决方法:Project->settings->C/C++: Preprocess。

      点击阅读更多内容
      关于金锄头网 - 版权申诉 - 免责声明 - 诚邀英才 - 联系我们
      手机版 | 川公网安备 51140202000112号 | 经营许可证(蜀ICP备13022795号)
      ©2008-2016 by Sichuan Goldhoe Inc. All Rights Reserved.