2013-05-03 234 views
2
[email protected]:~/Data$ g++ UDPEchoServer.cpp PracticalSocket.cpp -o udpskserv -lsocket -lnsl -mt 

我想在我的编译器Ubuntu的编译和我收到此错误c + +编译问题

cc1plus: error: unrecognized command line option ‘-mt’ 

请问是什么-mt,我尝试谷歌,但找不到任何信息。

如果我尝试省略-mt参数我得到这个错误

PracticalSocket.cpp: In constructor ‘SocketException::SocketException(const string&, bool)’: 
PracticalSocket.cpp:33:38: error: ‘strerror’ was not declared in this scope 
PracticalSocket.cpp: In function ‘void fillAddr(const string&, short unsigned int, sockaddr_in&)’: 
PracticalSocket.cpp:47:32: error: ‘memset’ was not declared in this scope 
PracticalSocket.cpp: In member function ‘void Socket::setLocalPort(short unsigned int)’: 
PracticalSocket.cpp:119:42: error: ‘memset’ was not declared in this scope 
PracticalSocket.cpp: In static member function ‘static short unsigned int Socket::resolveService(const string&, const string&)’: 
PracticalSocket.cpp:153:32: error: ‘atoi’ was not declared in this scope 
PracticalSocket.cpp: In member function ‘void UDPSocket::disconnect()’: 
PracticalSocket.cpp:291:40: error: ‘memset’ was not declared in this scope 
+3

您是否在PracticalSocket.cpp中包含''或''? – 2013-05-03 07:54:58

+5

出于好奇,如果你不知道'-mt'是什么,你为什么使用它? – juanchopanza 2013-05-03 07:55:19

+0

这里有两个独立的问题。要使事情正常工作,请删除-mt并修复编译错误。 – Arun 2013-05-03 07:56:38

回答

7

两个std::memsetstd::strerror<cstring>头声明,你需要#include那一个。

而GCC没有-mt选项。