• 11409阅读
  • 4回复

链接出错“undefined reference to"   [复制链接]

上一主题 下一主题
离线caichao07
 

只看楼主 倒序阅读 楼主  发表于: 2009-12-21
MainWin.o(.text+0x7d1): In function `MainWin::getHostInformation()':
: undefined reference to `QHostInfo::localHostName()'
MainWin.o(.text+0x7e8): In function `MainWin::getHostInformation()':
: undefined reference to `QHostInfo::fromName(QString const&)'
MainWin.o(.text+0x7f4): In function `MainWin::getHostInformation()':
: undefined reference to `QHostInfo::addresses() const'
MainWin.o(.text+0x822): In function `MainWin::getHostInformation()':
: undefined reference to `QHostAddress::toString() const'
MainWin.o(.text+0x851): In function `MainWin::getHostInformation()':
: undefined reference to `QHostInfo::~QHostInfo [in-charge]()'
MainWin.o(.text+0x8d5): In function `MainWin::getHostInformation()':
: undefined reference to `QHostInfo::~QHostInfo [in-charge]()'
MainWin.o(.text+0x92e): In function `MainWin::slotDetail()':
: undefined reference to `QNetworkInterface::allInterfaces()'
MainWin.o(.text+0x959): In function `MainWin::slotDetail()':
: undefined reference to `QNetworkInterface::QNetworkInterface[in-charge](QNetwo
rkInterface const&)'
MainWin.o(.text+0x99e): In function `MainWin::slotDetail()':
: undefined reference to `QNetworkInterface::name() const'
MainWin.o(.text+0xa7e): In function `MainWin::slotDetail()':
: undefined reference to `QNetworkInterface::hardwareAddress() const'
MainWin.o(.text+0xac0): In function `MainWin::slotDetail()':
: undefined reference to `QNetworkInterface::hardwareAddress() const'
MainWin.o(.text+0xba9): In function `MainWin::slotDetail()':
: undefined reference to `QNetworkInterface::addressEntries() const'
MainWin.o(.text+0xc00): In function `MainWin::slotDetail()':
: undefined reference to `QNetworkInterface::~QNetworkInterface [in-charge]()'
MainWin.o(.text+0xcdc): In function `MainWin::slotDetail()':
: undefined reference to `QNetworkAddressEntry::QNetworkAddressEntry[in-charge](
QNetworkAddressEntry const&)'
MainWin.o(.text+0xd6c): In function `MainWin::slotDetail()':
: undefined reference to `QNetworkAddressEntry::ip() const'
MainWin.o(.text+0xd81): In function `MainWin::slotDetail()':
: undefined reference to `QHostAddress::toString() const'
MainWin.o(.text+0xe38): In function `MainWin::slotDetail()':
: undefined reference to `QHostAddress::~QHostAddress [in-charge]()'
MainWin.o(.text+0xeed): In function `MainWin::slotDetail()':
: undefined reference to `QNetworkAddressEntry::netmask() const'
MainWin.o(.text+0xefc): In function `MainWin::slotDetail()':
: undefined reference to `QHostAddress::toString() const'
MainWin.o(.text+0xfbc): In function `MainWin::slotDetail()':
: undefined reference to `QHostAddress::~QHostAddress [in-charge]()'
MainWin.o(.text+0x1077): In function `MainWin::slotDetail()':
: undefined reference to `QNetworkAddressEntry::broadcast() const'
MainWin.o(.text+0x1086): In function `MainWin::slotDetail()':
: undefined reference to `QHostAddress::toString() const'
MainWin.o(.text+0x1146): In function `MainWin::slotDetail()':
: undefined reference to `QHostAddress::~QHostAddress [in-charge]()'
MainWin.o(.text+0x1188): In function `MainWin::slotDetail()':
: undefined reference to `QNetworkAddressEntry::~QNetworkAddressEntry [in-charge
]()'
MainWin.o(.text+0x143e): In function `MainWin::slotDetail()':
: undefined reference to `QNetworkInterface::~QNetworkInterface [in-charge]()'
MainWin.o(.text+0x161d): In function `MainWin::slotDetail()':
: undefined reference to `QNetworkAddressEntry::~QNetworkAddressEntry [in-charge
]()'
MainWin.o(.text+0x16c5): In function `MainWin::slotDetail()':
: undefined reference to `QHostAddress::~QHostAddress [in-charge]()'
MainWin.o(.text+0x17db): In function `MainWin::slotDetail()':
: undefined reference to `QHostAddress::~QHostAddress [in-charge]()'
MainWin.o(.gnu.linkonce.t._ZN5QListI12QHostAddressE13detach_helperEv+0x58): In f
unction `QList<QHostAddress>::detach_helper()':
: undefined reference to `QHostAddress::QHostAddress[in-charge](QHostAddress con
st&)'
MainWin.o(.gnu.linkonce.t._ZN5QListI12QHostAddressE4freeEPN9QListData4DataE+0x59
): In function `QList<QHostAddress>::free(QListData::Data*)':
: undefined reference to `QHostAddress::~QHostAddress [in-charge]()'
MainWin.o(.gnu.linkonce.t._ZN5QListI17QNetworkInterfaceE4freeEPN9QListData4DataE
+0x59): In function `QList<QNetworkInterface>::free(QListData::Data*)':
: undefined reference to `QNetworkInterface::~QNetworkInterface [in-charge]()'
MainWin.o(.gnu.linkonce.t._ZN5QListI20QNetworkAddressEntryE4freeEPN9QListData4Da
taE+0x59): In function `QList<QNetworkAddressEntry>::free(QListData::Data*)':
: undefined reference to `QNetworkAddressEntry::~QNetworkAddressEntry [in-charge
]()'
collect2: ld returned 1 exit status
make: *** [NetworkInfo] Error 1

相关代码段如下:

void MainWin :: getHostInformation()
{
  QString localHostName=QHostInfo :: localHostName();
  LineEditLocalHostName->setText(localHostName);
  
  QHostInfo hostInfo=QHostInfo :: fromName(localHostName);
  QList<QHostAddress> listAddress=hostInfo.addresses();
  if(!listAddress.isEmpty())
  {
    LineEditAddress->setText(listAddress.first().toString());
  }
}

void MainWin :: slotDetail()
{
  QString detail="";
  QList<QNetworkInterface> list=QNetworkInterface :: allInterfaces();
  for(int i=0; i<list.count(); i++)
  {
    QNetworkInterface interface=list.at(i);
    detail=detail + tr("Device: ") + interface.name() + "\n";
    QString hardwareAddress=interface.hardwareAddress();
    detail=detail + tr("HardwareAddress: ") + interface.hardwareAddress() + "\n";
    QList<QNetworkAddressEntry> entryList=interface.addressEntries();
    for(int j=0; j<entryList.count(); j++)
    {
      QNetworkAddressEntry entry=entryList.at(j);
      detail=detail + "\t" + tr("IP Address: ") + entry.ip().toString() + "\n";
      detail=detail + "\t" + tr("Netmask: ") + entry.netmask().toString() + "\n";
      detail=detail + "\t" + tr("Broadcast: ") +entry.broadcast().toString() + "\n";
    }
  }
  QMessageBox :: information(this, tr("Detail"), detail);
}
请哪位大侠指点,谢谢!!!
离线zyq840112

只看该作者 1楼 发表于: 2009-12-21
在.pro文件里面加入:QT += network
离线caichao07

只看该作者 2楼 发表于: 2009-12-21
太强了,谢谢!!!

能细说一下是什么原因吗,是不是我自己的路径配置有问题,所以qmake无法找到
离线wd007

只看该作者 3楼 发表于: 2009-12-21
在Qt Assistant中有说明,好多模块需要在.pro文件中加入类似的语句,以使得qmake认得这些模块。
欢迎访问我的博客,一起学习提高
http://blog.csdn.net/qter_wd007
离线蠢蠢欲懂
只看该作者 4楼 发表于: 2012-05-07
回 3楼(wd007) 的帖子
厉害,看助手解决问题,学习了
快速回复
限100 字节
 
上一个 下一个