新手求教:VS2013+QT5.42用QHostInfo::localHostName()和QNetworkInterface;报错
使用QNetworkInterface和QHostInfo获取主机名和本地网络信息时出现一下错误
1>address.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QHostAddress::~QHostAddress(void)" (__imp_??1QHostAddress@@QAE@XZ) referenced in function "public: __thiscall address::address(class QWidget *)" (??0address@@QAE@PAVQWidget@@@Z)
1>address.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class QString __thiscall QHostAddress::toString(void)const " (__imp_?toString@QHostAddress@@QBE?AVQString@@XZ) referenced in function "public: __thiscall address::address(class QWidget *)" (??0address@@QAE@PAVQWidget@@@Z)
1>address.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QNetworkAddressEntry::QNetworkAddressEntry(class QNetworkAddressEntry const &)" (__imp_??0QNetworkAddressEntry@@QAE@ABV0@@Z) referenced in function "public: __thiscall address::address(class QWidget *)" (??0address@@QAE@PAVQWidget@@@Z)
1>address.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QNetworkAddressEntry::~QNetworkAddressEntry(void)" (__imp_??1QNetworkAddressEntry@@QAE@XZ) referenced in function "public: __thiscall address::address(class QWidget *)" (??0address@@QAE@PAVQWidget@@@Z)
1>address.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class QHostAddress __thiscall QNetworkAddressEntry::ip(void)const " (__imp_?ip@QNetworkAddressEntry@@QBE?AVQHostAddress@@XZ) referenced in function "public: __thiscall address::address(class QWidget *)" (??0address@@QAE@PAVQWidget@@@Z)
1>address.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class QHostAddress __thiscall QNetworkAddressEntry::netmask(void)const " (__imp_?netmask@QNetworkAddressEntry@@QBE?AVQHostAddress@@XZ) referenced in function "public: __thiscall address::address(class QWidget *)" (??0address@@QAE@PAVQWidget@@@Z)
1>address.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class QHostAddress __thiscall QNetworkAddressEntry::broadcast(void)const " (__imp_?broadcast@QNetworkAddressEntry@@QBE?AVQHostAddress@@XZ) referenced in function "public: __thiscall address::address(class QWidget *)" (??0address@@QAE@PAVQWidget@@@Z)
1>address.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QNetworkInterface::QNetworkInterface(class QNetworkInterface const &)" (__imp_??0QNetworkInterface@@QAE@ABV0@@Z) referenced in function "public: __thiscall address::address(class QWidget *)" (??0address@@QAE@PAVQWidget@@@Z)
1>address.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QNetworkInterface::~QNetworkInterface(void)" (__imp_??1QNetworkInterface@@QAE@XZ) referenced in function "public: __thiscall address::address(class QWidget *)" (??0address@@QAE@PAVQWidget@@@Z)
1>address.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class QString __thiscall QNetworkInterface::name(void)const " (__imp_?name@QNetworkInterface@@QBE?AVQString@@XZ) referenced in function "public: __thiscall address::address(class QWidget *)" (??0address@@QAE@PAVQWidget@@@Z)
1>address.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class QString __thiscall QNetworkInterface::hardwareAddress(void)const " (__imp_?hardwareAddress@QNetworkInterface@@QBE?AVQString@@XZ) referenced in function "public: __thiscall address::address(class QWidget *)" (??0address@@QAE@PAVQWidget@@@Z)
1>address.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class QList<class QNetworkAddressEntry> __thiscall QNetworkInterface::addressEntries(void)const " (__imp_?addressEntries@QNetworkInterface@@QBE?AV?$QList@VQNetworkAddressEntry@@@@XZ) referenced in function "public: __thiscall address::address(class QWidget *)" (??0address@@QAE@PAVQWidget@@@Z)
1>address.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static class QList<class QNetworkInterface> __cdecl QNetworkInterface::allInterfaces(void)" (__imp_?allInterfaces@QNetworkInterface@@SA?AV?$QList@VQNetworkInterface@@@@XZ) referenced in function "public: __thiscall address::address(class QWidget *)" (??0address@@QAE@PAVQWidget@@@Z)
1>address.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static class QString __cdecl QHostInfo::localHostName(void)" (__imp_?localHostName@QHostInfo@@SA?AVQString@@XZ) referenced in function "public: __thiscall address::address(class QWidget *)" (??0address@@QAE@PAVQWidget@@@Z)
1>d:\documents\visual studio 2013\Projects\address\Win32\Debug\\address.exe : fatal error LNK1120: 14 unresolved externals
我知道使用这两个类是需要在你的工程文件里加上
QT+=network
在VS里面QT Project seting->Qt Modules里勾上QtNetwork 就等于 QT+=network
但是我按照以上方法做了还是报错是为什么?求助各位大神