在cygwin上编译套接字客户端和服务器 [英] compiling socket client and server on cygwin

查看:73
本文介绍了在cygwin上编译套接字客户端和服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好。

我正在尝试在

windows上编译linux套接字服务器和cygwin中的客户端。 g ++版本是3.3.1。来源是从这个

位置获得的:

http://www.linuxgazette.com/issue74/tougher.html

ServerSoccket.cpp显然编译正常。 Socket.cpp有问题。这是

我的输出:


$ make -f Makefile.txt

g ++ -c -o ServerSocket.o ServerSocket.cpp

g ++ -c -o Socket.o Socket.cpp

Socket.cpp:在成员函数`int Socket :: recv(std :: string&)中const'':

Socket.cpp:135:错误:`cout''未命名在命名空间`std''

Socket.cpp:在成员函数中`bool Socket: :connect(std :: basic_string< char,

std :: char_traits< char>,std :: allocator< char>>,int)'':

Socket .cpp:158:错误:`inet_pton''未声明(首先使用此函数)

Socket.cpp:158:错误:(每个未声明的标识符只报告一次

它出现在每个函数中。)

make:*** [Socket.o]错误1


cout如何在C ++中未声明?不是基本的基础之一吗?


请帮助,


Eugene。

解决方案

make -f Makefile.txt

g ++ -c -o ServerSocket.o ServerSocket.cpp

g ++ -c -o Socket.o Socket .cpp

Socket.cpp:在成员函数`int Socket :: recv(std :: string&)const'':

Socket.cpp:135:错误: `cout''名称空间`std''未声明'

Socket.cpp:在成员函数`bool Socket :: connect(std :: basic_string< char,

std: :char_traits< char>,std :: allocator< char>>,int)'':

Socket.cpp:158:错误:`inet_pton''未声明(首先使用此函数)

Socket.cpp:158:错误:(每个未声明的标识符只报告一次

它出现的每个函数。)

make:** * [Socket.o]错误1


cout如何在C ++中取消声明?不是基本的基础之一吗?


请帮助,


Eugene。


< blockquote>

" Eugene A" <螺***** @ mailandnews.com>在留言中写道

新闻:5a ****************************** @ news.teranew s。 com ...

你好。

我试图在
windows上的cygwin中编译一个linux套接字服务器和一个客户端。 g ++版本是3.3.1。来源是从这个位置获得的:

http://www.linuxgazette.com/issue74/tougher.html

ServerSoccket.cpp显然编译好了。 Socket.cpp有问题。这是我的输出:


make -f Makefile.txt
g ++ -c -o ServerSocket.o ServerSocket。 cpp
gocket -c -o Socket.o Socket.cpp
Socket.cpp:在成员函数`int Socket :: recv(std :: string&)const'':
Socket。 cpp:135:错误:`cout''未命名在命名空间`std''
Socket.cpp:在成员函数`bool
Socket :: connect(std :: basic_string< char,std :: char_traits< ; char> ;,std :: allocator< char>>,int)'':
Socket.cpp:158:错误:`inet_pton''未声明(首先使用此函数)
Socket.cpp: 158:错误:(每个未声明的标识符只报告一次它出现的每个函数
。)
make:*** [Socket.o]错误1

怎么能cout在C ++中未声明?这不是基本的基础之一吗?

请帮忙,




查看代码,作者未能包括< ;&的iostream GT;这是定义std :: cout的

头文件。包括< iostream>在Socket.cpp和你

应该没问题。


john


Hello.
I am trying to compile a linux socket server and a client in cygwin on
windows. The g++ version is 3.3.1. The source was obtained from this
location:

http://www.linuxgazette.com/issue74/tougher.html

ServerSoccket.cpp apparently compiles OK. Socket.cpp has a problem. Here''s
my output:

$ make -f Makefile.txt
g++ -c -o ServerSocket.o ServerSocket.cpp
g++ -c -o Socket.o Socket.cpp
Socket.cpp: In member function `int Socket::recv(std::string&) const'':
Socket.cpp:135: error: `cout'' undeclared in namespace `std''
Socket.cpp: In member function `bool Socket::connect(std::basic_string<char,
std::char_traits<char>, std::allocator<char> >, int)'':
Socket.cpp:158: error: `inet_pton'' undeclared (first use this function)
Socket.cpp:158: error: (Each undeclared identifier is reported only once for
each function it appears in.)
make: *** [Socket.o] Error 1

How can cout be undeclared in C++? Isnt that one of the basic basics?

Please help,

Eugene.

解决方案

make -f Makefile.txt
g++ -c -o ServerSocket.o ServerSocket.cpp
g++ -c -o Socket.o Socket.cpp
Socket.cpp: In member function `int Socket::recv(std::string&) const'':
Socket.cpp:135: error: `cout'' undeclared in namespace `std''
Socket.cpp: In member function `bool Socket::connect(std::basic_string<char,
std::char_traits<char>, std::allocator<char> >, int)'':
Socket.cpp:158: error: `inet_pton'' undeclared (first use this function)
Socket.cpp:158: error: (Each undeclared identifier is reported only once for
each function it appears in.)
make: *** [Socket.o] Error 1

How can cout be undeclared in C++? Isnt that one of the basic basics?

Please help,

Eugene.



"Eugene A" <lo*****@mailandnews.com> wrote in message
news:5a******************************@news.teranew s.com...

Hello.
I am trying to compile a linux socket server and a client in cygwin on
windows. The g++ version is 3.3.1. The source was obtained from this
location:

http://www.linuxgazette.com/issue74/tougher.html

ServerSoccket.cpp apparently compiles OK. Socket.cpp has a problem. Here''s
my output:


make -f Makefile.txt
g++ -c -o ServerSocket.o ServerSocket.cpp
g++ -c -o Socket.o Socket.cpp
Socket.cpp: In member function `int Socket::recv(std::string&) const'':
Socket.cpp:135: error: `cout'' undeclared in namespace `std''
Socket.cpp: In member function `bool Socket::connect(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int)'':
Socket.cpp:158: error: `inet_pton'' undeclared (first use this function)
Socket.cpp:158: error: (Each undeclared identifier is reported only once for each function it appears in.)
make: *** [Socket.o] Error 1

How can cout be undeclared in C++? Isn''t that one of the basic basics?

Please help,



Look at the code, the author has failed to include <iostream> which is the
header file that defined std::cout. Include <iostream> in Socket.cpp and you
should be OK.

john


这篇关于在cygwin上编译套接字客户端和服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆