|
初学ACE,编译了库以后运行ACE自带的example都没有问题,自己建一个工程编写一个简单的小程序就不行了
报错:(2个)
MSVCRT.lib(crtexe.obj) : error LNK2001: 无法解析的外部符号 _main
fatal error LNK1120: 1 个无法解析的外部命令
问什么我打开ACE自带的工程编译就没问题,高手给来看看,程序就是C++网络编程第一卷里面的一个小程序
- #include "ace/INET_Addr.h"
- #include "ace/SOCK_Connector.h"
- #include "ace/SOCK_Stream.h"
- #define BUFSIZ 8
- int main (int argc, char *argv[])
- {
- const char *pathname = "index.html";
- const char *server_hostname = "www.163.com";
- ACE_SOCK_Connector connector;
- ACE_SOCK_Stream peer;
- ACE _INET_Addr peer_addr;
- if (peer_addr.set (80, server_hostname) == -1)
- return 1;
- else if (connector.connect (peer, peer_addr) == -1)
- return 1;
- char buf [BUFSIZ];
- iovec iov[3];
- iov[0].iov_base = "GET ";
- iov[0].iov_len = 4; // Length of "GET ".
- iov[1].iov_base = pathname;
- iov[1].iov_len = strlen (pathname);
- iov[2] iov_base = " HTTP/1.0\r\n\r\n" ;
- iov[2].iov_len = 13; // Length of " HTTP/1.0\r\n\r\n";
- if (peer.sendv_n (iov, 3) == -1)
- 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;
- }
复制代码 |
|