Results 1 to 3 of 3

Thread: WinMain@16 Issue

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Maui, Hawaii
    Posts
    120
    Thanks
    65
    Thanked 4 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default WinMain@16 Issue

    I am trying to build a server with no Qt classes using qmake (since it creates Makefiles so well) with MinGW mixed in there.

    I am able to build GUIs fine, but this server fails with:

    [...]libmingw32.a(main.o):main.c.text+0x104): undefined reference to 'WinMain@16'.
    There are thousands of posts on the web about this error, and I think I've tried all the fixes:

    1. Changed int main() to void main()
    2. Since this is a server with no GUI, I added CONFIG += console (same error with or without console)
    3. Added "QT -= gui" to .pro file
    4. Added "LIBS += -lmingw32 -mwindows" to .pro file
    5. Added "QT_CXXFLAGS+=-mwindows" to .pro file
    6. Added "CXXFLAGS += -mwindows"
    7. Added "LIBS += -u _WinMain@16" to .pro file
    8. Reversed library order (I get the same error but from a cygwin library)
    9. Added explicity path to libmingw32.a (although I think it found it)
    10. Added "using namespace std" in the file with my main()
    11. Added these two lines: "int WinMain@16();" and "intWinMain@16() { }"
    12. Added these two lines: "int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmd, int show);" and "int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmd, int show) { return 0; }"
    13. Removed all main() functions
    14. Added "LIBS += -lmingw32 -mwindows"
    15. Added "LIBS += -lgdi32 -lkernel32 -luser32 -lshell32 -lm"
    16. Moved mingw32 libraries to beginning of LIBS


    None of these solutions remove the "undefined reference to 'WinMain@16'" error.

    Have I left anything off?

  2. #2
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: WinMain@16 Issue

    Run: qmake -project from command prompt then open the project and build it.
    If this doesn't work, create a simple project that replicates the problem and upload it here.

  3. The following user says thank you to Zlatomir for this useful post:

    mhoover (26th May 2010)

  4. #3
    Join Date
    Jan 2006
    Location
    Maui, Hawaii
    Posts
    120
    Thanks
    65
    Thanked 4 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: WinMain@16 Issue

    Hmm ... that seemed to get me past the linking issue. Now it's saying that it's missing certain header files.

    This seems strange to me because I thought the linking happened at the end.

    My whole project file is different now, so it's hard to say what is different exactly.

Similar Threads

  1. WinMain@16 compiler error in Qt examples
    By Tvt204 in forum Installation and Deployment
    Replies: 11
    Last Post: 26th January 2010, 19:30
  2. MS C++ issue
    By sepehr in forum Installation and Deployment
    Replies: 4
    Last Post: 29th December 2008, 23:45
  3. Suddenly getting 'undefined ref to 'WinMain@16'
    By Doug Broadwell in forum Qt Programming
    Replies: 8
    Last Post: 4th December 2008, 18:11
  4. UI issue.
    By kaushal_gaurav in forum Qt Programming
    Replies: 2
    Last Post: 13th August 2008, 11:41
  5. Cannot find file: winmain.pro in Qt installation
    By jivanr in forum Installation and Deployment
    Replies: 3
    Last Post: 11th June 2007, 12:22

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
  •  
Qt is a trademark of The Qt Company.