Results 1 to 9 of 9

Thread: Suddenly getting 'undefined ref to 'WinMain@16'

  1. #1
    Join Date
    Jan 2006
    Location
    Berkeley California
    Posts
    109
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Suddenly getting 'undefined ref to 'WinMain@16'

    After doing a:

    qmake -project "CONFIG += debug", "win32: CONFIG += console"
    qmake n2.pro

    (which I've done many times in the past, I'm getting:

    make -f Makefile.Debug
    make[1]: Entering directory `C:/Data/Qt/mverse/n2'
    g++ -mthreads -Wl,-enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-subsystem,console -o "debug\n2.exe" debug\q
    extserialbase.o debug\qextserialport.o debug\win_qextserialport.o -L"c:\Data\Qt\4.2.3\lib" -lQtGuid4 -lQtCored4
    C:/Data/Qt/MinGW/bin/../lib/gcc/mingw32/3.4.2/../../../libmingw32.a(main.o)(.text+0x106):main.c: undefined reference to `WinMain@16'
    collect2: ld returned 1 exit status
    make[1]: *** [debug\n2.exe] Error 1

    I'm not sure how to go about debugging this.

    Thanks, Doug

  2. #2
    Join Date
    May 2007
    Posts
    7
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Suddenly getting 'undefined ref to 'WinMain@16'

    Can you show us your main.c file?

  3. #3
    Join Date
    Aug 2008
    Posts
    132
    Thanks
    23
    Thanked 3 Times in 3 Posts

    Default Re: Suddenly getting 'undefined ref to 'WinMain@16'

    Hi,

    I've been getting similar types of errors, don't have a message now, but in my case the problems are also in mingw libraries or in qt libraries. I've only experienced this with Qt Creater 0.9 Alpha, so I assumed there's something wrong with the libraries shipped with it.

    I haven't tried to solve it yet though,
    Cheers
    Jaco

  4. #4
    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: Suddenly getting 'undefined ref to 'WinMain@16'

    Adding or removing "CONFIG += console" requires rebuilding the application (or at least the source file containing main() function). Unfortunately rebuilding doesn't happen automatically because the source file doesn't change.
    J-P Nurmi

  5. #5
    Join Date
    Jan 2006
    Location
    Berkeley California
    Posts
    109
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Suddenly getting 'undefined ref to 'WinMain@16'

    Here's the code for my main.cpp:


    Qt Code:
    1. #include <QApplication>
    2. #include <QtGui>
    3. #include "MainWindow.h"
    4. #include "comm.h"
    5. #include "state.h"
    6. #include "error.h"
    7. #include "main.h"
    8.  
    9. #include "ctl_cfg_assoc.h"
    10.  
    11.  
    12.  
    13. //- GLOBAL OBJECT POINTERS -//
    14.  
    15. MainWindow* mw;
    16.  
    17.  
    18. QByteArray qbaEmpty;
    19.  
    20.  
    21.  
    22.  
    23. //----------------------------------------------------------------------------------
    24. // REIMPLEMENTATION OF QApplication::notify() TO CATCH OTHERWISE UNCAUGHT ERRORS |
    25. //---------------------------------------------------------------------------------------------------------
    26. // *FIXME* We want to remove this for production.
    27.  
    28. qMyApp::qMyApp( int argc, char* argv[] ) : QApplication( argc, argv ) {};
    29.  
    30. qMyApp::~qMyApp() {};
    31.  
    32. //---------------------------------------------------------------------------------------------------------
    33.  
    34. bool qMyApp::notify( QObject* qoReceiver, QEvent* qeEvent ) {
    35.  
    36. try {
    37.  
    38. return QApplication::notify( qoReceiver, qeEvent );
    39.  
    40. } catch( Fatal_Error& E ) {
    41.  
    42. qDebug() << "\n" << E.Error_String() << "\n";
    43. throw;
    44.  
    45. } catch( Base_Error& E ) {
    46.  
    47. qDebug() << "\n" << E.Error_String() << "\n";
    48. throw;
    49.  
    50. } catch( ... ) {
    51.  
    52. qDebug("\nUnknown Error Caught\n");
    53. throw;
    54. }
    55. };
    56. //---------------------------------------------------------------------------------------------------------
    To copy to clipboard, switch view to plain text mode 





    Qt Code:
    1. //---------
    2. // MAIN |
    3. //---------------------------------------------------------------------------------------------------------
    4.  
    5. int main(int argc, char *argv[]) {
    6.  
    7.  
    8. //-- CREATE APPLICATION OBJECT --//
    9.  
    10. qMyApp app(argc, argv);
    11.  
    12. //-- CREATE STATE OBJECT --//
    13.  
    14. Init_State(); // Must come before creating the Serial Port.
    15.  
    16. //-- CREATE SERIAL PORT OBJECT --//
    17.  
    18. Init_SerialPort( 2 ); // Create COM2.
    19.  
    20. //-- CREATE CtlCfgAssoc OBJECT --//
    21.  
    22. Init_CtlCfgAssoc();
    23.  
    24. //-- CREATE MAIN WINDOW OBJECT WITH SCROLLBARS --//
    25.  
    26. mw = new MainWindow;
    27. sa = new QScrollArea;
    28. sa->setWidget( mw );
    29. sa->show();
    30.  
    31. //-- RUN --//
    32.  
    33. return app.exec();
    34. }
    35. //---------------------------------------------------------------------------------------------------------
    To copy to clipboard, switch view to plain text mode 

    But I haven't changed anything in it from before when it was working. It seems to be an issue with 'main.c' in libmingw32.a but I don't know what it's doing.

    Doug
    Last edited by jpn; 3rd December 2008 at 08:12. Reason: missing [code] tags

  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: Suddenly getting 'undefined ref to 'WinMain@16'

    As I told you, rebuild the application:
    sh Code:
    1. make clean
    2. qmake
    3. make
    To copy to clipboard, switch view to plain text mode 
    Last edited by wysota; 2nd January 2009 at 23:21.
    J-P Nurmi

  7. #7
    Join Date
    Jan 2006
    Location
    Berkeley California
    Posts
    109
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Suddenly getting 'undefined ref to 'WinMain@16'

    Sorry if I wasn't clear; I have rebuilt the application and still get this error.

    Doug

  8. #8
    Join Date
    Jan 2006
    Location
    Berkeley California
    Posts
    109
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Suddenly getting 'undefined ref to 'WinMain@16'

    Found the problem (but not what is causing it). For some reason the 'qmake -project' is making a project file with only a subset of the header and source files in it, when I add all the files (I assume that missing the file with main() in it was causing the error) and running qmake it seems to be fine again.

    Doug

  9. #9
    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: Suddenly getting 'undefined ref to 'WinMain@16'

    Well, "qmake -project" is supposed to be something that you run once in the beginning of a project to generate an initial project file. It's not intended to be used to maintain the project file.
    J-P Nurmi

Similar Threads

  1. QPSQL problem
    By LoneWolf in forum Installation and Deployment
    Replies: 60
    Last Post: 4th November 2009, 14:22
  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.