Results 1 to 3 of 3

Thread: "Undefined reference to htons@4" type errors with Qt Creator

  1. #1
    Join Date
    Oct 2009
    Posts
    50
    Thanks
    22
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default "Undefined reference to htons@4" type errors with Qt Creator

    I tried to compile a source code which I found on internet with Qt Creator.My problem is,when I try to compile the source code with Qt Creator's menu item "Build Project",it gives these types of errors:
    "
    Undefined reference to htons@4
    Undefined reference to `gethostbyname@4'
    Undefined reference to ...
    ...

    "

    Why does this problem happen?What should I do?

  2. #2
    Join Date
    May 2008
    Posts
    155
    Thanked 15 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: "Undefined reference to htons@4" type errors with Qt Creator

    Quote Originally Posted by Awareness View Post
    I tried to compile a source code which I found on internet with Qt Creator.My problem is,when I try to compile the source code with Qt Creator's menu item "Build Project",it gives these types of errors:
    "
    Undefined reference to htons@4
    Undefined reference to `gethostbyname@4'
    Undefined reference to ...
    ...

    "

    Why does this problem happen?What should I do?
    You need to add a library containing definitions for these functions to the 'LIBS' variable in your profile. I.e. something like LIBS += some.lib

  3. #3
    Join Date
    Jul 2010
    Posts
    72
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt/Embedded Qt Jambi
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: "Undefined reference to htons@4" type errors with Qt Creator

    Hi
    I get the same linking error when compiling libmodbus on Windows - code that uses winsock.
    What library to add? How to add Ws_2_32.lib or Ws_2_32.dll to a Qt project what to wright in .pro file?

Similar Threads

  1. QPSQL problem
    By LoneWolf in forum Installation and Deployment
    Replies: 60
    Last Post: 4th November 2009, 15:22
  2. Undefined reference to crt
    By derektaprell in forum Installation and Deployment
    Replies: 0
    Last Post: 20th October 2009, 09:34
  3. how to add static library into qmake
    By Namrata in forum Qt Tools
    Replies: 1
    Last Post: 20th November 2007, 18:33
  4. error undefined reference ...............
    By amit_pansuria in forum Qt Programming
    Replies: 2
    Last Post: 8th June 2007, 15:28
  5. how to correctly compile threads support?
    By srhlefty in forum Installation and Deployment
    Replies: 9
    Last Post: 25th June 2006, 20: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.