因为最近要开发一个服务器项目,也打算学习一下ACE,所以就拿Cygwin玩玩ACE,
下载ACE5.5源码包之后,就马上开始编译:
首先参考ACE-Install.htm,其中说到Cygwin下的ACE的编译方法:
-
Open a Cygwin shell. Set your PATH environment variable so your Cygwin bin directory is first:
% export PATH=//c/cygwin/bin:$PATH
Note Cygwin uses ``/'' as directory separator, and ``//X'' as a notation for Win32 drive X. Note also that you can't use ``c:/cygwin/bin'' because, for Cygwin, ``:'' is path separator character, as in UNIX.
- Add an ACE_ROOT environment variable pointing to the root of your ACE wrappers source tree:
% export ACE_ROOT=c:/work/cygwin/ACE_wrappers
Note here you can't use the ``//X'' Cygwin notation as this is seen by Cygwin's compiler and it doesn't support that (it does support ``/'' as directory separator however).
From now on, we will refer to the root directory of the ACE source tree as $ACE_ROOT.
- Create a file called config.h in the $ACE_ROOT/ace directory that contains:
#include "ace/config-cygwin32.h"
- Create a file called platform_macros.GNU in the $ACE_ROOT/include/makeinclude directory containing:
include $(ACE_ROOT)/include/makeinclude/platform_cygwin32.GNU
In the above text, don't replace $(ACE_ROOT) with the actual directory, GNU make will take the value from the environment variable you defined previously.
- On the Cygwin shell, change to the $ACE_ROOT/ace directory and run make:
% cd $ACE_ROOT/ace % make
This should create libACE.dll (the Win32 shared library) and libACE.dll.a (the Win32 import library for the DLL). Note the name for the ACE DLL on Cygwin follows the UNIX convention.
If you want static libs also, you may run:
% make static_libs=1
但是死活编译不成功,make返回Error2,烦死。
google一下,大部分人都是这样编译过了,但是本机就死活不行,
后来终于找到了一个文章,里面说了一种不同于官方文档的编译方法:
先设置ACE_ROOT环境,命令:“vi /etc/profile”在其中加入4行
ACE_ROOT=~/ACE_wrappers export ACE_ROOTLD_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”,
然后执行官方文档的3,4步骤,
最后:
% cd $ACE_ROOT/ace % make static_libs=1
经过漫长的等待,终于搞定!发文记录一下。
1、定义ACE_ROOT
export ACE_ROOT=/datas/ACE_wrappers;
2、定义配置文件,$ACE_ROOT/ace/config.h,该文件包含和平台相关的配置文件:
如在linux平台下,内容为
#include "ace/config-linux.h"
3、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
4、Note that because ACE builds shared libraries, you'll need to set LD_LIBRARY_PATH (or equivalent for your platform) to the directory where binary version of the ACE library is built into. For example, you probably want to do something like the following:
% setenv LD_LIBRARY_PATH $ACE_ROOT/lib:$LD_LIBRARY_PATH
5、
When all this is done, hopefully all you'll need to do is type:
% make
6、在fedora6上的config.h的第一行加上如下语句:
#define ACE_GCC_HAS_TEMPLATE_INSTANTIATION_VISIBILITY_ATTRS 1