ACE的问题 linux 下无法编译

109 views
Skip to first unread message

papamms

unread,
Apr 13, 2006, 3:17:49 AM4/13/06
to 高性能网络编程邮件列表
文件
#include "ace/SOCK_Acceptor.h"
#include "ace/SOCK_Stream.h"
#include "ace/Log_Msg.h"
#include "ace/Init_ACE.h"
#include "ace/OS_NS_stdio.h"
#include "ace/OS_NS_string.h"
#include "ace/Acceptor.h"

#define SIZE_DATA 18
#define SIZE_BUF 1024
#define NO_ITERATIONS 5

//#define ACE_HAS_TOKENS_LIBRARY

class Server
{
public:
Server (int port): server_addr_(port),peer_acceptor_(server_addr_)
{
data_buf_= new char[SIZE_BUF];
}
//Handle the connection once it has been established. Here the
//connection is handled by reading SIZE_DATA amount of data from the
//remote and then closing the connection stream down.
int handle_connection()
{
// Read data from client
for(int i=0;i<NO_ITERATIONS;i++)
{
int byte_count=0;
if( (byte_count=new_stream_.recv_n (data_buf_, SIZE_DATA, 0))==-1)
ACE_ERROR ((LM_ERROR, "%p\n", "Error in recv"));
else
{
data_buf_[byte_count]=0;
ACE_DEBUG((LM_DEBUG,"Server received %s \n",data_buf_));
}
}
// Close new endpoint
if (new_stream_.close () == -1)
ACE_ERROR ((LM_ERROR, "%p\n", "close"));
return 0;
}
//Use the acceptor component peer_acceptor_ to accept the connection
//into the underlying stream new_stream_. After the connection has been
//established call the handle_connection() method.
int accept_connections ()
{
if (peer_acceptor_.get_local_addr (server_addr_) == -1)
ACE_ERROR_RETURN ((LM_ERROR,"%p\n","Error in get_local_addr"),1);
ACE_DEBUG ((LM_DEBUG,"Starting server at port %d\n",
server_addr_.get_port_number ()));

// Performs the iterative server activities.
while(1)
{
ACE_Time_Value timeout (ACE_DEFAULT_TIMEOUT);
if (peer_acceptor_.accept (new_stream_, &client_addr_, &timeout)== -1)
{
ACE_ERROR ((LM_ERROR, "%p\n", "accept"));
continue;
}
else
{
ACE_DEBUG((LM_DEBUG,
"Connection established with remote %s:%d\n",
client_addr_.get_host_name(),client_addr_.get_port_number()));
//Handle the connection
handle_connection();
}
}
}
private:
char *data_buf_;
ACE_INET_Addr server_addr_;
ACE_INET_Addr client_addr_;
ACE_SOCK_Acceptor peer_acceptor_;
ACE_SOCK_Stream new_stream_;
};
int main (int argc, char *argv[])
{
if(argc<2)
{
ACE_ERROR((LM_ERROR,"Usage %s <port_num>", argv[0]));
ACE_OS::exit(1);
}
Server server(ACE_OS::atoi(argv[1]));
server.accept_connections();
return 0;
}


文件肯定没问题
vc 2003 可以编译 运行正常

linux 下 我
1. 在/usr/local目录下解压缩:
tar -xzvf ACE-5.3+TAO-1.3.tar.gz
2.cd ACE_wrappers
find -name \*dsp -o -name \*dsw -o -name \*bor|xargs rm -f
3.export ACE_ROOT="/usr/local/ACE_wrappers"
4.cd $ACE_ROOT/ace
ln -s config-linux.h config.h
5.cd $ACE_ROOT/include/makeinclude
ln -s platform_linux.GNU platform_macros.GNU
6.export LD_LIBRARY_PATH=$ACE_ROOT/ace:$ACE_ROOT/lib:$LD_LIBRARY_PATH
7.cd $ACE_ROOT
make
基本上是这么做的

$ACE_ROOT/ace 下面有lib文件了
/home/aaa/ACE_wrappers/ace/libACE.so
/home/aaa/ACE_wrappers/ace/libACE.so.5.5.0

编译命令
g++ test.cpp -I$ACE_ROOT -L$ACE_ROOT

错误

如果 使用g++ test.cpp -I$ACE_ROOT -L$ACE_ROOT -c 是可以的
所以应该是连接上面的错


铁错误的代码
test.cpp:92:2: warning: no newline at end of file
/tmp/ccVkVPDD.o(.text+0x24): In function `main':
: undefined reference to `ACE_Log_Msg::last_error_adapter()'
/tmp/ccVkVPDD.o(.text+0x2c): In function `main':
: undefined reference to `ACE_Log_Msg::instance()'
/tmp/ccVkVPDD.o(.text+0x46): In function `main':
: undefined reference to `ACE_Log_Msg::conditional_set(char const*,
int, int, int)'
/tmp/ccVkVPDD.o(.text+0x60): In function `main':
: undefined reference to `ACE_Log_Msg::log(ACE_Log_Priority, char
const*, ...)'
/tmp/ccVkVPDD.o(.text+0x6d): In function `main':
: undefined reference to `ACE_OS::exit(int)'
/tmp/ccVkVPDD.o(.gnu.linkonce.t._ZN6ServerD1Ev+0x36): In function
`Server::~Server()':
: undefined reference to `ACE_INET_Addr::~ACE_INET_Addr()'
/tmp/ccVkVPDD.o(.gnu.linkonce.t._ZN6ServerD1Ev+0x50): In function
`Server::~Server()':
: undefined reference to `ACE_INET_Addr::~ACE_INET_Addr()'
/tmp/ccVkVPDD.o(.gnu.linkonce.t._ZN6ServerD1Ev+0x70): In function
`Server::~Server()':
: undefined reference to `ACE_INET_Addr::~ACE_INET_Addr()'
/tmp/ccVkVPDD.o(.gnu.linkonce.t._ZN6Server18accept_connectionsEv+0x18):
In function `Server::accept_connections()':
: undefined reference to `ACE_SOCK::get_local_addr(ACE_Addr&) const'
/tmp/ccVkVPDD.o(.gnu.linkonce.t._ZN6Server18accept_connectionsEv+0x25):
In function `Server::accept_connections()':
: undefined reference to `ACE_Log_Msg::last_error_adapter()'
/tmp/ccVkVPDD.o(.gnu.linkonce.t._ZN6Server18accept_connectionsEv+0x2d):
In function `Server::accept_connections()':
: undefined reference to `ACE_Log_Msg::instance()'
/tmp/ccVkVPDD.o(.gnu.linkonce.t._ZN6Server18accept_connectionsEv+0x47):
In function `Server::accept_connections()':
: undefined reference to `ACE_Log_Msg::conditional_set(char const*,
int, int, int)'
/tmp/ccVkVPDD.o(.gnu.linkonce.t._ZN6Server18accept_connectionsEv+0x61):
In function `Server::accept_connections()':
: undefined reference to `ACE_Log_Msg::log(ACE_Log_Priority, char
const*, ...)'
/tmp/ccVkVPDD.o(.gnu.linkonce.t._ZN6Server18accept_connectionsEv+0x75):
In function `Server::accept_connections()':
: undefined reference to `ACE_Log_Msg::last_error_adapter()'
/tmp/ccVkVPDD.o(.gnu.linkonce.t._ZN6Server18accept_connectionsEv+0x7d):
In function `Server::accept_connections()':
: undefined reference to `ACE_Log_Msg::instance()'
/tmp/ccVkVPDD.o(.gnu.linkonce.t._ZN6Server18accept_connectionsEv+0x97):
In function `Server::accept_connections()':
: undefined reference to `ACE_Log_Msg::conditional_set(char const*,
int, int, int)'
/tmp/ccVkVPDD.o(.gnu.linkonce.t._ZN6Server18accept_connectionsEv+0xbf):
In function `Server::accept_connections()':
: undefined reference to `ACE_Log_Msg::log(ACE_Log_Priority, char
const*, ...)'
/tmp/ccVkVPDD.o(.gnu.linkonce.t._ZN6Server18accept_connectionsEv+0xfa):
In function `Server::accept_connections()':
: undefined reference to `ACE_SOCK_Acceptor::accept(ACE_SOCK_Stream&,
ACE_Addr*, ACE_Time_Value*, int, int) const'
/tmp/ccVkVPDD.o(.gnu.linkonce.t._ZN6Server18accept_connectionsEv+0x107):
In function `Server::accept_connections()':
: undefined reference to `ACE_Log_Msg::last_error_adapter()'
/tmp/ccVkVPDD.o(.gnu.linkonce.t._ZN6Server18accept_connectionsEv+0x10f):
In function `Server::accept_connections()':
: undefined reference to `ACE_Log_Msg::instance()'
/tmp/ccVkVPDD.o(.gnu.linkonce.t._ZN6Server18accept_connectionsEv+0x129):
In function `Server::accept_connections()':
: undefined reference to `ACE_Log_Msg::conditional_set(char const*,
int, int, int)'
/tmp/ccVkVPDD.o(.gnu.linkonce.t._ZN6Server18accept_connectionsEv+0x143):
In function `Server::accept_connections()':
: undefined reference to `ACE_Log_Msg::log(ACE_Log_Priority, char
const*, ...)'
/tmp/ccVkVPDD.o(.gnu.linkonce.t._ZN6Server18accept_connectionsEv+0x150):
In function `Server::accept_connections()':
: undefined reference to `ACE_Log_Msg::last_error_adapter()'
/tmp/ccVkVPDD.o(.gnu.linkonce.t._ZN6Server18accept_connectionsEv+0x158):
In function `Server::accept_connections()':
: undefined reference to `ACE_Log_Msg::instance()'
/tmp/ccVkVPDD.o(.gnu.linkonce.t._ZN6Server18accept_connectionsEv+0x172):
In function `Server::accept_connections()':
: undefined reference to `ACE_Log_Msg::conditional_set(char const*,
int, int, int)'
/tmp/ccVkVPDD.o(.gnu.linkonce.t._ZN6Server18accept_connectionsEv+0x19a):
In function `Server::accept_connections()':
: undefined reference to `ACE_INET_Addr::get_host_name() const'
/tmp/ccVkVPDD.o(.gnu.linkonce.t._ZN6Server18accept_connectionsEv+0x1ad):
In function `Server::accept_connections()':
: undefined reference to `ACE_Log_Msg::log(ACE_Log_Priority, char
const*, ...)'
/tmp/ccVkVPDD.o(.gnu.linkonce.t._ZN6Server17handle_connectionEv+0x47):
In function `Server::handle_connection()':
: undefined reference to `ACE_Log_Msg::last_error_adapter()'
/tmp/ccVkVPDD.o(.gnu.linkonce.t._ZN6Server17handle_connectionEv+0x4f):
In function `Server::handle_connection()':
: undefined reference to `ACE_Log_Msg::instance()'
/tmp/ccVkVPDD.o(.gnu.linkonce.t._ZN6Server17handle_connectionEv+0x69):
In function `Server::handle_connection()':
: undefined reference to `ACE_Log_Msg::conditional_set(char const*,
int, int, int)'
/tmp/ccVkVPDD.o(.gnu.linkonce.t._ZN6Server17handle_connectionEv+0x83):
In function `Server::handle_connection()':
: undefined reference to `ACE_Log_Msg::log(ACE_Log_Priority, char
const*, ...)'
/tmp/ccVkVPDD.o(.gnu.linkonce.t._ZN6Server17handle_connectionEv+0x98):
In function `Server::handle_connection()':
: undefined reference to `ACE_Log_Msg::last_error_adapter()'
/tmp/ccVkVPDD.o(.gnu.linkonce.t._ZN6Server17handle_connectionEv+0xa0):
In function `Server::handle_connection()':
: undefined reference to `ACE_Log_Msg::instance()'
/tmp/ccVkVPDD.o(.gnu.linkonce.t._ZN6Server17handle_connectionEv+0xba):
In function `Server::handle_connection()':
: undefined reference to `ACE_Log_Msg::conditional_set(char const*,
int, int, int)'
/tmp/ccVkVPDD.o(.gnu.linkonce.t._ZN6Server17handle_connectionEv+0xd1):
In function `Server::handle_connection()':
: undefined reference to `ACE_Log_Msg::log(ACE_Log_Priority, char
const*, ...)'
/tmp/ccVkVPDD.o(.gnu.linkonce.t._ZN6Server17handle_connectionEv+0xed):
In function `Server::handle_connection()':
: undefined reference to `ACE_SOCK_Stream::close()'
/tmp/ccVkVPDD.o(.gnu.linkonce.t._ZN6Server17handle_connectionEv+0xfa):
In function `Server::handle_connection()':
: undefined reference to `ACE_Log_Msg::last_error_adapter()'
/tmp/ccVkVPDD.o(.gnu.linkonce.t._ZN6Server17handle_connectionEv+0x102):
In function `Server::handle_connection()':
: undefined reference to `ACE_Log_Msg::instance()'
/tmp/ccVkVPDD.o(.gnu.linkonce.t._ZN6Server17handle_connectionEv+0x11c):
In function `Server::handle_connection()':
: undefined reference to `ACE_Log_Msg::conditional_set(char const*,
int, int, int)'
/tmp/ccVkVPDD.o(.gnu.linkonce.t._ZN6Server17handle_connectionEv+0x136):
In function `Server::handle_connection()':
: undefined reference to `ACE_Log_Msg::log(ACE_Log_Priority, char
const*, ...)'
/tmp/ccVkVPDD.o(.gnu.linkonce.t._ZN3ACE6recv_nEiPvjiPK14ACE_Time_ValuePj+0x1f):
In function `ACE::recv_n(int, void*, unsigned int, int, ACE_Time_Value
const*, unsigned int*)':
: undefined reference to `ACE::recv_n_i(int, void*, unsigned int, int,
unsigned int*)'
/tmp/ccVkVPDD.o(.gnu.linkonce.t._ZN3ACE6recv_nEiPvjiPK14ACE_Time_ValuePj+0x41):
In function `ACE::recv_n(int, void*, unsigned int, int, ACE_Time_Value
const*, unsigned int*)':
: undefined reference to `ACE::recv_n_i(int, void*, unsigned int, int,
ACE_Time_Value const*, unsigned int*)'
/tmp/ccVkVPDD.o(.gnu.linkonce.t._ZN14ACE_Time_Value3setEll+0x1e): In
function `ACE_Time_Value::set(long, long)':
: undefined reference to `ACE_Time_Value::normalize()'
/tmp/ccVkVPDD.o(.gnu.linkonce.t._ZN6ServerC1Ei+0x1b): In function
`Server::Server(int)':
: undefined reference to `ACE_INET_Addr::ACE_INET_Addr(unsigned short,
unsigned int)'
/tmp/ccVkVPDD.o(.gnu.linkonce.t._ZN6ServerC1Ei+0x2d): In function
`Server::Server(int)':
: undefined reference to `ACE_INET_Addr::ACE_INET_Addr()'
/tmp/ccVkVPDD.o(.gnu.linkonce.t._ZN6ServerC1Ei+0x4e): In function
`Server::Server(int)':
: undefined reference to `ACE_SOCK_Acceptor::ACE_SOCK_Acceptor(ACE_Addr
const&, int, int, int, int)'
/tmp/ccVkVPDD.o(.gnu.linkonce.t._ZN6ServerC1Ei+0xcf): In function
`Server::Server(int)':
: undefined reference to `ACE_INET_Addr::~ACE_INET_Addr()'
/tmp/ccVkVPDD.o(.gnu.linkonce.t._ZN6ServerC1Ei+0xec): In function
`Server::Server(int)':
: undefined reference to `ACE_INET_Addr::~ACE_INET_Addr()'
/tmp/ccVkVPDD.o(.gnu.linkonce.t._ZN11ACE_SOCK_IOC2Ev+0xd): In function
`ACE_SOCK_IO::ACE_SOCK_IO()':
: undefined reference to `ACE_SOCK::ACE_SOCK()'
collect2: ld returned 1 exit status

Stone Jiang

unread,
Apr 13, 2006, 3:26:22 AM4/13/06
to dev4s...@googlegroups.com
ACE已经5.5了,你怎么还在5.3呢?

HuYi

unread,
Apr 13, 2006, 3:39:03 AM4/13/06
to dev4s...@googlegroups.com
Stone Jiang wrote:
> ACE已经5.5了,你怎么还在5.3呢?
>
升级挺麻烦的,不喜欢等待重新编译,我个人开发的时候,还是用的老板本。

Stone Jiang

unread,
Apr 13, 2006, 3:39:26 AM4/13/06
to dev4s...@googlegroups.com
我也是,我现在硬盘上有一堆旧版本了.
把旧的目录重命名
好在下载,解压
吃饭前编译
吃饭后就OK了.
--
Take care
Stone Jiang

papamms

unread,
Apr 13, 2006, 3:43:06 AM4/13/06
to 高性能网络编程邮件列表
... 我用的是5.5 但铁过来的是5.3 的安装包

解决具体的问题先

你们是在linux 下面用吗?

你们怎么安装的?

Stone Jiang

unread,
Apr 13, 2006, 3:49:01 AM4/13/06
to dev4s...@googlegroups.com
我在FC下按部就盘的编译成功.
 
现在我在Windows下
 
另外,由于GCC如果版本过高的话,将无法编译5.4.9以前的版本.
我不知道是不是这个原因造成你不能编译


 
On 4/13/06, papamms <ppms...@gmail.com> wrote:

HuYi

unread,
Apr 13, 2006, 3:48:41 AM4/13/06
to dev4s...@googlegroups.com
我装的时候比较顺利,稍微改了一下配置,就是对应linux那种,然后直接运行安
装脚本。
没有遇到什么错误。

--
☆==☆☆==☆☆==☆☆==☆☆==☆☆==☆
NEC Solutions(China)Co.,Ltd.
ソフトウェア開発事業部
  大連第一開発部
  胡 毅(コ キ)
♪連絡先
◇ TEL (86)0411-84754455-232
◇ e-Mail huy...@gmail.com
◇ GTalk huy...@gmail.com
◇ BLOG www.cppblog.com/huyi
☆==☆☆==☆☆==☆☆==☆☆==☆☆==☆

papamms

unread,
Apr 13, 2006, 3:52:32 AM4/13/06
to 高性能网络编程邮件列表
我在FC下按部就盘的编译成功

怎么按部就班的

运行那个sh 文件吗?

Li Jie

unread,
Apr 13, 2006, 4:16:12 AM4/13/06
to dev4s...@googlegroups.com
未定义的引用,是链接错误。编译参数中再加一个-lACE,链接上libACE.so

在 06-4-13,papamms<ppms...@gmail.com> 写道:

papamms

unread,
Apr 13, 2006, 4:18:20 AM4/13/06
to 高性能网络编程邮件列表
-lACE

会错误的

说没有

Stone Jiang

unread,
Apr 13, 2006, 4:20:40 AM4/13/06
to dev4s...@googlegroups.com

ACE是ACE_wrappers所在目录
在环境变量在设置

 
On 4/13/06, papamms <ppms...@gmail.com> wrote:
-lACE

会错误的

说没有

papamms

unread,
Apr 13, 2006, 4:57:31 AM4/13/06
to 高性能网络编程邮件列表
哦 thanks

问题 终于解决了

我用的是 -lace

应该是 -lACE

Reply all
Reply to author
Forward
0 new messages