ACE编程,无法解析外部符号
客户端程序:P#ifdef _DEBUG#pragmacomment (lib,"aced.lib")
#else
#pragmacomment (lib,"ace.lib")
#endif
#include"ace/INET_Addr.h"
#include"ace/SOCK_Connector.h"
#include"ace/SOCK_Stream.h"
#include"iostream"
using namespace std;
const int BUFSIZE=10;
int main(int argc,char *argv[])
{
const char *pathname=
argc>1?argv:"index.html";
const char *server_hostname=
argc>2?argv:"ace.ece.uci.edu";
ACE_SOCK_Connector connector;
ACE_SOCK_Stream peer;
ACE_INET_Addr peer_addr;
if(peer_addr.set(80,server_hostname)==-1)
//if(peer_addr.set(80,"202.3.123.43"))
{
cout<<"set failed"<<endl;
return 1;
}
else if(connector.connect(peer,peer_addr)==-1)
{
cout<<"connect failed"<<endl;
return 1;
}
char buf;
iovec iov;
iov.iov_base="GET";
iov.iov_len=4;
iov.iov_base=(char*)pathname;
iov.iov_len=strlen(pathname);
iov.iov_base="HTTP/1.0\r\n\r\n";
iov.iov_len=13;
if(peer.sendv_n(iov,3==-1))
{
cout<<"send failed"<<endl;
return 1;
}
for(ssize_t n;(n=peer.recv(buf,sizeof buf))>0;)
ACE::write_n(ACE_STDOUT,buf,n);
return peer.close()==-1?1:0;
}
服务器端程序:
#ifdef _DEBUG
#pragmacomment (lib,"aced.lib")
#else
#pragmacomment (lib,"ace.lib")
#endif
#include"iostream"
#include"ace/INET_Addr.h"
#include"ace/SOCK_Connector.h"
#include"ace/SOCK_Acceptor.h"
#include"ace/SOCK_Stream.h"
#include"ace/Mem_Map.h"
#include"ace/Auto_Ptr.h"
using namespace std;
extern char *get_url_pathname(ACE_SOCK_Stream*);
int main()
{
ACE_INET_Addr server_addr;
ACE_SOCK_Acceptor acceptor;
ACE_SOCK_Stream peer;
if(server_addr.set(80)==-1)
{
cout<<"set failed"<<endl;
return 1;
}
if(acceptor.open(server_addr)==-1)
{
cout<<"acceptor failed"<<endl;
return 1;
}
for(;;)
{
if(acceptor.accept(peer)==-1)
{
cout<<"acceptor faile"<<endl;
return 1;
}
peer.disable(ACE_NONBLOCK);
ACE_Auto_Array_Ptr <char> pathname(get_url_pathname(&peer));
ACE_Mem_Map mapped_file (pathname.get());
if(peer.send_n(mapped_file.addr(),mapped_file.size())==-1)
return 1;
peer.close();
}
return acceptor.close()==-1?1:0;
}
客户端编译没问题,服务器端编译错误提示:
1>------ 已启动生成: 项目: ace_server, 配置: Debug Win32 ------
1>正在链接...
1>serve.obj : error LNK2019: 无法解析的外部符号 "int __cdecl ace_main_i(int,char * * const)" (?ace_main_i@@YAHHQAPAD@Z),该符号在函数 "private: virtual int __thiscall ACE_Main::run_i(int,char * * const)" (?run_i@ACE_Main@@EAEHHQAPAD@Z) 中被引用
1>serve.obj : error LNK2019: 无法解析的外部符号 "char * __cdecl get_url_pathname(class ACE_SOCK_Stream *)" (?get_url_pathname@@YAPADPAVACE_SOCK_Stream@@@Z),该符号在函数 "int __cdecl ace_main_i(void)" (?ace_main_i@@YAHXZ) 中被引用
1>F:\ace_server\Debug\ace_server.exe : fatal error LNK1120: 2 个无法解析的外部命令
1>生成日志保存在“file://f:\ace_server\ace_server\Debug\BuildLog.htm”
1>ace_server - 3 个错误,0 个警告
========== 生成: 0 已成功, 1 已失败, 0 最新, 0 已跳过 ==========
请高手指教: ACE_TMAIN 版主,能说详细点吗?谢谢。我刚刚学习ACE。这个是《c++网络编程》里的例子 一般ACE使用ACE_TMAIN代替main作为主函数的入口
int ACE_TMAIN(int argc, ACE_TCHAR* argv[])
另,get_url_pathname 没有具体实现吧
页:
[1]