Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 4

Qt-interest Archive, June 2007
qt main winmain qmain


Message 1 in thread

I've got some trouble with a Qt program compiled with Mingw gcc crashing 
in the WinMain function of qtmain_win.cpp.

The program does not appear to be using my own main() routine at all. 
This program compiles and runs well under Linux.

Is there some documentation on this that I'm missing? Google is 
returning very few results for things such as "QT_NEEDS_QMAIN" or 
qtmain_win.cpp. The error I get is "Runtime Error" (program name) 
"abnormal program termination".

Thanks.

--
 [ signature omitted ] 

Message 2 in thread

"Patrick Draper" <pdraper@xxxxxxxxx> wrote in message 
news:4678037E.5000907@xxxxxxxxxxxx
> I've got some trouble with a Qt program compiled with Mingw gcc crashing 
> in the WinMain function of qtmain_win.cpp.
>
> The program does not appear to be using my own main() routine at all. 
> This program compiles and runs well under Linux.
>
> Is there some documentation on this that I'm missing? Google is 
> returning very few results for things such as "QT_NEEDS_QMAIN" or 
> qtmain_win.cpp. The error I get is "Runtime Error" (program name) 
> "abnormal program termination".

Grep'ing for QT_NEEDS_QMAIN in the Qt sources shows that it prevents a 
main() symbol from being exported by your application. Instead, main is 
#define'ed to qMain (both in qwindowdefs.h and in qtmain_win.cpp), which 
is then called by the WinMain implementation. IIRC this is because if a 
main() entry point exists on MinGW, WinMain is never called (and WinMain 
does a few things that are important for Windows applications).

Which call in the WinMain implementation is it crashing at? Does this 
reproduce with any example?

Volker


--
 [ signature omitted ] 

Message 3 in thread

Volker Hilsheimer wrote:
> Grep'ing for QT_NEEDS_QMAIN in the Qt sources shows that it prevents a
> main() symbol from being exported by your application. Instead, main is 
> #define'ed to qMain (both in qwindowdefs.h and in qtmain_win.cpp), which 
> is then called by the WinMain implementation. IIRC this is because if a 
> main() entry point exists on MinGW, WinMain is never called (and WinMain 
> does a few things that are important for Windows applications).
>   


Thanks for the very clear explanation, I wasn't expecting this behavior 
so I wasn't looking for it. I'm normally a Linux developer and these 
kinds of tricks aren't that common on Linux. I've figured out what I was 
doing wrong with the Windows build.

Patrick

--
 [ signature omitted ]