2013-05-03 172 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選項。