Results 1 to 6 of 6

Thread: undefined reference to GetAdaptersInfo@8

  1. #1
    Join Date
    Apr 2009
    Posts
    11
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default undefined reference to GetAdaptersInfo@8

    Hi all,

    When I tried to build my test code,it prompts this error: undefined reference to GetAdaptersInfo@8 although I've included iphlpapi.h....

    The following is my test code eg:
    Qt Code:
    1. #include <QtCore/QCoreApplication>
    2. #include <windows.h>
    3. #include <iphlpapi.h>
    4. #include <stdio.h>
    5. #include <stdlib.h>
    6. #include <string.h>
    7. //#include <netcon.h>
    8.  
    9. PIP_ADAPTER_INFO pAdapterInfo;
    10. ULONG bufferLen;
    11.  
    12. int main(int argc, char *argv[])
    13. {
    14. QCoreApplication a(argc, argv);
    15.  
    16. if( GetAdaptersInfo(pAdapterInfo, &bufferLen) != ERROR_SUCCESS )
    17. {
    18.  
    19. }
    20.  
    21. return a.exec();
    22. }
    To copy to clipboard, switch view to plain text mode 
    Need some help with this...

    Secondly,How do I include netcon.h and its required files for use in my application?I tried #include <netcon.h> but it says no such file or directory...

    Thanks in advanced.

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: undefined reference to GetAdaptersInfo@8

    how this issue related with Qt?
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: undefined reference to GetAdaptersInfo@8

    You need to link against the library providing GetAdaptersInfo(). According to MSDN it's Iphlpapi.lib so try adding this to your .pro file:
    qmake Code:
    1. win32:LIBS += -lIphlpap
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: undefined reference to GetAdaptersInfo@8

    If you are using WinXP or later you should use a different function:

    Quote Originally Posted by msdn
    On Windows XP and later: Use the GetAdaptersAddresses function instead of GetAdaptersInfo.
    By the way, if you're programming for windows using winapi, pasting the offending function in MSDN might be a better idea than seeking help on a forum dedicated to Qt
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Apr 2009
    Posts
    11
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: undefined reference to GetAdaptersInfo@8

    hi all,

    thanks for the reply.The reason I posted here is because I felt the issue is trying to link the proper libraries required to do the work in Qt,which I've encountered many problems trying to do so.The error I've mentioned here could be because I did not link it properly.

    Anyway,thanks to jpn I've included the link in my .pro file but I use libiphlpapi.a instead of Iphlpapi.lib since it is found in C:\Qt\2009.01\mingw\lib folder.I rebuild it and it works so far.

    thanks wysota for the info I will check it out as well.

  6. #6
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: undefined reference to GetAdaptersInfo@8

    Quote Originally Posted by remy06 View Post
    but I use libiphlpapi.a instead of Iphlpapi.lib
    That's why I proposed using "-lIphlpap" since it should work for both cases.
    J-P Nurmi

Similar Threads

  1. xerces - undefined reference
    By eleanor in forum General Programming
    Replies: 3
    Last Post: 27th April 2009, 13:16
  2. how to add static library into qmake
    By Namrata in forum Qt Tools
    Replies: 1
    Last Post: 20th November 2007, 17:33
  3. MS Sql native driver??
    By LordQt in forum Qt Programming
    Replies: 4
    Last Post: 9th October 2007, 13:41
  4. error undefined reference ...............
    By amit_pansuria in forum Qt Programming
    Replies: 2
    Last Post: 8th June 2007, 14:28
  5. how to correctly compile threads support?
    By srhlefty in forum Installation and Deployment
    Replies: 9
    Last Post: 25th June 2006, 19:15

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.