- 论坛徽章:
- 0
|
安装:
按照安装包所带的安装说明,有两种方法:
方法一:Building ACE with GNU Autoconf
疑问之一:在使用../configure的时候提示说找不到命令或者是文件,是我方法不对还是其他?
方法二:Using the Traditional ACE/GNU Configuration
(1),首先确信已经安装“GNU make 3.79.1 or greater on your system”
(2),设置ACE_ROOT和LD_LIBRARY_PATH环境变量,如果是更改/etc/profile文件,执行soure /etc/profile不用重新启动就能使得配置生效
我的设置如下:
[root@localhost build]# echo $ACE_ROOT
/usr/local/ACE_wrappers
[root@localhost build]# echo $LD_LIBRARY_PATH
/usr/local/ACE_wrappers/ace:/usr/local/ACE_wrappers/lib
疑问之二:echo $LD_LIBRARY只在root用户下有输出,在普通用户下输出空白,echo $ACE_ROOT在超级用户和普通用户下面都会输出正确路径,暂时搞不懂!
(3),Create a configuration file, $ACE_ROOT/ace/config.h,文件内容如下:
[root@localhost build]# cat $ACE_ROOT/ace/config.h
#include "ace/config-linux.h"
(4),Create a build configuration file, $ACE_ROOT/include/makeinclude/platform_macros.GNU,文件内容如下:
[root@localhost build]# cat $ACE_ROOT/include/makeinclude/platform_macros.GNU
include $(ACE_ROOT)/include/makeinclude/platform_linux.GNU
注意,include前面不能添加"#",#在此文件中是“注释”的意思
(5),make,如果没有错误提示就成功了!
疑问之三:官方的安装文档此时说“This will build the ACE library, tests, the examples, and the sample applications”,此时的make和make,make install有什么区别呢?
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
利用自带的例子进行测试:
(1)在$ACE_ROOT/examples/Synch中,修改proc_sema.cpp文件如下:
#include "ace/OS_NS_stdio.h"
在main函数中,也就是在ACE_TMAIN函数中开始的地方添加一句如下内容,其他的内容不用管:
ACE_OS::printf("Hello,World! \n");
(2)执行make,OK后运行,打印出hello,World!字符串。
(3)如果运行时装在不到share object,可能是lib路径问题,因为.so文件是程序运行过程中
装载的,不是在编译的时候,因此要设置LD_LIBRARY_PATH:
[root@localhost yufei] export LD_LIBRARY_PATH=/home/jet/ACE_wrappers/lib:$LD_LIBRARY_PATH
-------------------------------------------------------------------
自己编写一个测试程序:
[root@localhost yufei]# cat main.cpp
#define ACE_NTRACE 0 //设置为0 开启TRACE
#include "ace/Log_Msg.h"
void foo(void);
int ACE_TMAIN(int, ACE_TCHAR *[])
{
ACE_TRACE(ACE_TEXT ("main"));
ACE_DEBUG( (LM_INFO, ACE_TEXT ("%IHi Momn")) );
foo();
ACE_DEBUG( (LM_INFO, ACE_TEXT ("%IGoodnightn")) );
return 0;
}
void foo(void)
{
ACE_TRACE( ACE_TEXT ("foo") );
ACE_DEBUG( (LM_INFO, ACE_TEXT ("%IHowdy Pardnern")) );
}
[root@localhost yufei]# cat Makefile
BIN = main
BUILD = $(VBIN)
SRC = $(addsuffix .cpp, $(BIN))
#LIBS = -lMyOtherLib
LDFLAGS = -L$(ACE_ROOT)/lib
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
[root@localhost yufei]#
运行结果如下:
[root@localhost yufei]# dir
main main.cpp Makefile
[root@localhost yufei]# ./main
(3085936304) calling main in file `main.cpp' on line 7
Hi Momn (3085936304) calling foo in file `main.cpp' on line 18
Howdy Pardnern (3085936304) leaving foo
Goodnightn(3085936304) leaving main
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
最后一个疑问:如上所示make安装的ACE是不是就是我开发时所需要的环境?开发一个分布式网络程序 。
[ 本帖最后由 neobob 于 2006-8-24 16:12 编辑 ] |
|