5
meme@ubuntu:~/Data$ g++ UDPEchoServer.cpp PracticalSocket.cpp -o udpskserv -lsocket -lnsl -mt

我试图在我的编译器 ubuntu 上进行编译,我收到了这个错误

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
4

1 回答 1

14

两者std::memsetstd::strerror都在<cstring>标题中声明,您需要#include那个。

而 GCC 没有-mt选择。

于 2013-05-03T07:58:12.317 回答