开发者

How to hide console window on Windows when using scons-qt4 plugin?

When I'm building on Windows with scons-qt4 plugin, my application always opens a console window, even though it has its own windows. With QMak开发者_如何学Goe, you could force application to do the same by adding CONFIG += console or something similar, but the default behaviour is to suppress it. QMake can handle it - I'm sure scons can, too.

The only way I see so far to solve this problem would be to use #ifdef around int main():

#ifdef WIN32
int WinMain (int _argc, char **_argv)
#else
int main (int _argc, char **_argv)
#endif

But that's just abominable!


So, it seems, my question was almost already answered here. Now, applied to scons, these two lines did it for me:

if (env ['PLATFORM'] == 'win32'):
    env.Append (LINKFLAGS = ['-Wl,-subsystem,windows'])

Also, kind thanks to the folks on the [scons-users] mailing list. In particular, David Van Maren pointed out that:

You might look for whether you are linking against the qtmain library. The latest Qt documentation only says this about it:

--------------- The qtmain Library

qtmain is a helper library that enables the developer to write a cross-platform main() function on Windows and on the Symbian platform. If you do not use qmake or other build tools such as CMake, then you need to link against theqtmain library.


It may not be related, but I think that once I added it to the link, the bogus console disappeared for our Qt gui applications.

This may be another way to solve the problem, for example, when program is compiled with other tools than GCC + MinGW.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜