Results 1 to 12 of 12

Thread: WinMain@16 compiler error in Qt examples

  1. #1
    Join Date
    Dec 2009
    Posts
    8
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Question WinMain@16 compiler error in Qt examples

    Hi,

    I've got an interesting error in qt when running the examples from the welcome screen of qt 1.3.0.

    I've tried several of the examples, including 2dpainting under the OpenGl category. Each example gives me 2 errors and about 200 warnings. The errors are:

    1. undefined reference to 'WinMain@16" c:\nokia\qt\2009.05_new\mingw\bin\...\lib\gcc\ming w32\4.4.0\..\..\..\libmingw32.a(main.o):main.c:

    2. collect2: ld returned 1 exit status

    and the warnings are all "undefined reference to '_imp___Z.....'"

    I'm running qt creator 1.3 and qt 4.6.0. Oddly enough the MyFirstApp program I've written myself compiles and runs fine. I'm compiling in qt using the default configuration (my OS is WinXP.)


    So, how can I compile/run the examples in qt?
    Thanks.

  2. #2
    Join Date
    Oct 2009
    Posts
    364
    Thanks
    10
    Thanked 37 Times in 36 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: WinMain@16 compiler error in Qt examples

    That's indeed strange, Qt sdk usually installs/runs out of the box.
    check if the project settings are detecting the correct Qt version under Projects-Build Settings-Qt Version.
    Compare the settings between your program and the example.

  3. #3
    Join Date
    Dec 2009
    Posts
    8
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: WinMain@16 compiler error in Qt examples

    Thanks for your suggestion.

    I've posted the Projects->Build Settings for the stickman example program (chosen at random):

    General
    using Qt version: Default Qt Version (4.6.0)
    with tool chain MinGW
    building in C:\Nokia\Qt\2009.05_new\qt\examples\animation\stic kman
    Build Steps
    QMake: qmake.exe stickman.pro -spec win32-g++ -r
    Make: mingw32-make.exe -w in C:\Nokia\Qt\2009.05_new\qt\examples\animation\stic kman
    Clean Steps
    Make: mingw32-make.exe clean -w in C:\Nokia\Qt\2009.05_new\qt\examples\animation\stic kman
    Build Environment
    Summary: No changes to Environment

    And for the program I've written:

    General
    using Qt version: Default Qt Version (4.6.0)
    with tool chain MinGW
    building in C:\Programming\Nokia\Paint\PainT
    Build Steps
    QMake: qmake.exe PainT.pro -spec win32-g++ -r
    Make: mingw32-make.exe -w in C:\Programming\Nokia\Paint\PainT
    Clean Steps
    Make: mingw32-make.exe clean -w in C:\Programming\Nokia\Paint\PainT
    Build Environment
    Summary: No changes to Environment


    I haven't touched any of these settings.

  4. #4
    Join Date
    Oct 2009
    Posts
    364
    Thanks
    10
    Thanked 37 Times in 36 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: WinMain@16 compiler error in Qt examples

    have you tried building from the Qt command prompt?
    Show compile output (inside Qt Creator) from both of these projects just after a Clean-all.

    I noticed the folder name 2009.05_new - is that the standard location?
    I am not suggesting this is happening to you, but I once had some weirdness due to having multiple MS compilers (VC++ express 2008, VB express and an old visual studio etc) installed. Only after removing all these and the platform sdk I was able to get it working again.

    [ducks] or you could try to reinstall Qt

  5. #5
    Join Date
    Dec 2009
    Posts
    8
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: WinMain@16 compiler error in Qt examples

    Thanks for your suggestions.

    I'm not sure what you mean by building from the Qt command prompt (which means the answer is probably no), but I did a clean all on both projects.

    The compile output for PaintT is:

    Running build steps for project PainT...
    Configuration unchanged, skipping QMake step.
    Starting: C:/Nokia/Qt/2009.05_new/mingw/bin/mingw32-make.exe -w
    mingw32-make: Entering directory `C:/Programming/Nokia/Paint/PainT'
    C:/Nokia/Qt/2009.05_new/mingw/bin/mingw32-make -f Makefile.Debug
    mingw32-make[1]: Entering directory `C:/Programming/Nokia/Paint/PainT'
    c:\Nokia\Qt\2009.05_new\qt\bin\uic.exe paint.ui -o ui_paint.h
    g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"..\..\..\..\Nokia\Qt\2009.05_new\qt\include\QtCo re" -I"..\..\..\..\Nokia\Qt\2009.05_new\qt\include\QtGu i" -I"..\..\..\..\Nokia\Qt\2009.05_new\qt\include" -I"..\..\..\..\Nokia\Qt\2009.05_new\qt\include\Acti veQt" -I"debug" -I"." -I"..\..\..\..\Nokia\Qt\2009.05_new\qt\mkspecs\win3 2-g++" -o debug\main.o main.cpp
    g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"..\..\..\..\Nokia\Qt\2009.05_new\qt\include\QtCo re" -I"..\..\..\..\Nokia\Qt\2009.05_new\qt\include\QtGu i" -I"..\..\..\..\Nokia\Qt\2009.05_new\qt\include" -I"..\..\..\..\Nokia\Qt\2009.05_new\qt\include\Acti veQt" -I"debug" -I"." -I"..\..\..\..\Nokia\Qt\2009.05_new\qt\mkspecs\win3 2-g++" -o debug\paint.o paint.cpp
    C:/Nokia/Qt/2009.05_new/qt/bin\moc.exe -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"..\..\..\..\Nokia\Qt\2009.05_new\qt\include\QtCo re" -I"..\..\..\..\Nokia\Qt\2009.05_new\qt\include\QtGu i" -I"..\..\..\..\Nokia\Qt\2009.05_new\qt\include" -I"..\..\..\..\Nokia\Qt\2009.05_new\qt\include\Acti veQt" -I"debug" -I"." -I"..\..\..\..\Nokia\Qt\2009.05_new\qt\mkspecs\win3 2-g++" -D__GNUC__ -DWIN32 paint.h -o debug\moc_paint.cpp
    g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"..\..\..\..\Nokia\Qt\2009.05_new\qt\include\QtCo re" -I"..\..\..\..\Nokia\Qt\2009.05_new\qt\include\QtGu i" -I"..\..\..\..\Nokia\Qt\2009.05_new\qt\include" -I"..\..\..\..\Nokia\Qt\2009.05_new\qt\include\Acti veQt" -I"debug" -I"." -I"..\..\..\..\Nokia\Qt\2009.05_new\qt\mkspecs\win3 2-g++" -o debug\moc_paint.o debug\moc_paint.cpp
    g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -mthreads -Wl -Wl,-subsystem,windows -o debug\PainT.exe debug/main.o debug/paint.o debug/moc_paint.o -L"c:\Nokia\Qt\2009.05_new\qt\lib" -lmingw32 -lqtmaind -lQtGuid4 -lQtCored4
    mingw32-make[1]: Leaving directory `C:/Programming/Nokia/Paint/PainT'
    mingw32-make: Leaving directory `C:/Programming/Nokia/Paint/PainT'
    Exited with code 0.

    The clean all output for stickman is:

    Running build steps for project stickman...
    Starting: C:/Nokia/Qt/2009.05_new/mingw/bin/mingw32-make.exe clean -w
    mingw32-make: Entering directory `C:/Nokia/Qt/2009.05_new/qt/examples/animation/stickman'
    C:/Nokia/Qt/2009.05_new/mingw/bin/mingw32-make -f Makefile.Debug clean
    mingw32-make[1]: Entering directory `C:/Nokia/Qt/2009.05_new/qt/examples/animation/stickman'
    del tmp\moc\debug_shared\moc_stickman.cpp tmp\moc\debug_shared\moc_node.cpp tmp\moc\debug_shared\moc_graphicsview.cpp
    del tmp\rcc\debug_shared\qrc_stickman.cpp
    del tmp\obj\debug_shared\main.o tmp\obj\debug_shared\stickman.o tmp\obj\debug_shared\animation.o tmp\obj\debug_shared\node.o tmp\obj\debug_shared\lifecycle.o tmp\obj\debug_shared\graphicsview.o tmp\obj\debug_shared\moc_stickman.o tmp\obj\debug_shared\moc_node.o tmp\obj\debug_shared\moc_graphicsview.o tmp\obj\debug_shared\qrc_stickman.o
    mingw32-make[1]: Leaving directory `C:/Nokia/Qt/2009.05_new/qt/examples/animation/stickman'
    C:/Nokia/Qt/2009.05_new/mingw/bin/mingw32-make -f Makefile.Release clean
    mingw32-make[1]: Entering directory `C:/Nokia/Qt/2009.05_new/qt/examples/animation/stickman'
    del tmp\moc\release_shared\moc_stickman.cpp tmp\moc\release_shared\moc_node.cpp tmp\moc\release_shared\moc_graphicsview.cpp
    del tmp\rcc\release_shared\qrc_stickman.cpp
    del tmp\obj\release_shared\main.o tmp\obj\release_shared\stickman.o tmp\obj\release_shared\animation.o tmp\obj\release_shared\node.o tmp\obj\release_shared\lifecycle.o tmp\obj\release_shared\graphicsview.o tmp\obj\release_shared\moc_stickman.o tmp\obj\release_shared\moc_node.o tmp\obj\release_shared\moc_graphicsview.o tmp\obj\release_shared\qrc_stickman.o
    mingw32-make[1]: Leaving directory `C:/Nokia/Qt/2009.05_new/qt/examples/animation/stickman'
    mingw32-make: Leaving directory `C:/Nokia/Qt/2009.05_new/qt/examples/animation/stickman'
    Could Not Find C:\Nokia\Qt\2009.05_new\qt\examples\animation\stic kman\tmp\moc\release_shared\moc_stickman.cpp
    Could Not Find C:\Nokia\Qt\2009.05_new\qt\examples\animation\stic kman\tmp\rcc\release_shared\qrc_stickman.cpp
    Could Not Find C:\Nokia\Qt\2009.05_new\qt\examples\animation\stic kman\tmp\obj\release_shared\main.o
    Exited with code 0.

    The compiler output (all 602 lines of it) for stickman is attached.

    The folder name 2009.05_new is because this is my second try at installing qt. (I uninstalled the first but the folder wouldn't delete and qt won't install in an existing directory - the original folder is gone now.) The re-install didn't allow me to compile the examples.

    As for the MS compilers, I do have VS 2003, 2005, and 2008 compilers installed. I hesitate to uninstall these as I'm not sure Microsoft allows re-installs of VB 2005 Express now that you can't get it anymore.
    Attached Files Attached Files

  6. #6
    Join Date
    Oct 2009
    Posts
    364
    Thanks
    10
    Thanked 37 Times in 36 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: WinMain@16 compiler error in Qt examples

    weird
    exit qt creator and try the following:
    remove debug/release folders
    remove the makefiles
    remove any object_script files
    remove xxx.pro.user file
    try building again
    If that doesn't work can you reproduce in a minimal project and attach it?

    To the gurus: does anybody know how to show the environment info that gets shown when you do a configure? That's how I tracked down my messed up environment when I had all those compilers/SDKs installed.

  7. #7
    Join Date
    Dec 2009
    Posts
    8
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: WinMain@16 compiler error in Qt examples

    No go.

    What I've done is taken the stickman example program and removed pretty much all the code. What's left is the stickman.h file and main.cpp.

    I removed the files you suggested from this stripped down version, then "built" the code just to confirm errors were still present. This is what is attached.

    Thanks.
    Attached Files Attached Files

  8. #8
    Join Date
    Oct 2009
    Posts
    364
    Thanks
    10
    Thanked 37 Times in 36 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: WinMain@16 compiler error in Qt examples

    I think you snipped too much
    I took the stickman example from my Qt installation and it built fine. However, I noticed that weird tmp folder. It has some trouble finding that judging from your compile output.
    Try getting rid of that folder so you are only left with the following files:
    animations folder
    animations cpp/h
    graphicsview cpp/h
    lifecycle cpp/h
    main.cpp
    node.cpp/h
    stickman cpp/h
    stickman.pro
    stickman.qrc

    I have attached a zip file just in case.
    try to open that in qt creator and give it a shot.
    Attached Files Attached Files

  9. The following user says thank you to schnitzel for this useful post:

    Tvt204 (26th January 2010)

  10. #9
    Join Date
    Jan 2010
    Posts
    1
    Qt products
    Qt4
    Platforms
    Windows Symbian S60

    Default Re: WinMain@16 compiler error in Qt examples

    Same problem here but with a new QT Creator 1.3.1 installation on Windows XP SP3.
    I've downloaded stickman.zip file supplied and I'm getting same error again.
    I can't run any demo or empty application.

    c:/qt/2010.01/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../libmingw32.a(main.o):main.c::-1: error: undefined reference to `WinMain@16'
    :-1: error: collect2: ld returned 1 exit status
    Last edited by Albarian; 26th January 2010 at 15:40.

  11. #10
    Join Date
    Dec 2009
    Posts
    8
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: WinMain@16 compiler error in Qt examples

    Get this: The file you attached WORKS for me, provided I don't put it into the same folder as the stickman example.

    My example files are under C:/Nokia/Qt/2009.05_new/qt/examples/animation/stickman_ex/stickman.pro , etc
    Anything I create goes under C:/Programming/Nokia/stickman_ex , etc
    Now, why does this identical folder work when I put it in any directory other than the default directory?

    So, what I've done is moved my entire examples directory to C:/Nokia/Qt and now all of the examples I've tested compile.
    Albarian, I'm running Win XP SP3 as well. Does moving the examples directory help you?

  12. The following user says thank you to Tvt204 for this useful post:

    joandelason (20th March 2010)

  13. #11
    Join Date
    Oct 2009
    Posts
    364
    Thanks
    10
    Thanked 37 Times in 36 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: WinMain@16 compiler error in Qt examples

    Quote Originally Posted by Tvt204 View Post
    Get this: The file you attached WORKS for me, provided I don't put it into the same folder as the stickman example.

    My example files are under C:/Nokia/Qt/2009.05_new/qt/examples/animation/stickman_ex/stickman.pro , etc
    Anything I create goes under C:/Programming/Nokia/stickman_ex , etc
    Now, why does this identical folder work when I put it in any directory other than the default directory?

    So, what I've done is moved my entire examples directory to C:/Nokia/Qt and now all of the examples I've tested compile.
    Albarian, I'm running Win XP SP3 as well. Does moving the examples directory help you?
    I'm glad it worked for you, although I'm not sure why. When you copied the files/folder from my archive into the original example's folder, did you completely delete all contents *before* copying the new stuff into it?

  14. #12
    Join Date
    Dec 2009
    Posts
    8
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: WinMain@16 compiler error in Qt examples

    Actually, I not only deleted the folder's contents, but I also deleted the folder. Then recreated the folder and copied the files from your archive into it. Must just be something weird with winXP. Thanks for your help.

  15. The following user says thank you to Tvt204 for this useful post:

    ohlfsen (24th February 2010)

Tags for this Thread

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.