windowsconsolewarningsscons

hiding console window LNK4044 warning


I'm using scons to compile my C++ app disabling console window but I can't get this done. Searching in the internet, and in StackOverflow, I found that this line would work
env.Append( LINKFLAGS=['-Wl,-subsystem,windows'] )
The problem is I always receive a warning message that this line is ignored. This is the message:

LINK : warning LNK4044: unrecognized option '/Wl,-subsystem,windows'; ignored

I've already tried: env.Append( LINKFLAGS=['-Wl,-subsystem:windows'] )
env.Append( LINKFLAGS='-Wl,-subsystem,windows' )
env.Append( LINKFLAGS=['/Wl,-subsystem,windows'] )
env.Append( LINKFLAGS=['/Wl,-subsystem:windows'] )

Like you noticed, many possibilities I've done, but no sucess. Below I post some part of my SConstruct file. Any help is very appreciated.

Thanks for all replies

# GNU GCC
if 'gcc' in env[ 'compiler' ]:
env.Append( CCFLAGS='-Wall', CPPDEFINES=['GCC'] )
if int( debug ):
    env.Append( CCFLAGS='-g', LINKFLAGS='-g' )
else:
    env.Append( CCFLAGS='-O2', LINKFLAGS='-O2' )`
# MSVC v9 
elif 'msvc' in env['compiler']:
env.Append( LINKCOM=[ 'mt.exe -nologo -manifest ${TARGET}.manifest -outputresource:$TARGET;1' ] )
env.Append( SHLINKCOM=[ 'mt.exe -nologo -manifest ${TARGET}.manifest -outputresource:$TARGET;2' ] )
env.Append( CCFLAGS='/W3 /EHsc', CPPDEFINES=[ 'WIN32', 'WINDOWS', 'MSVC', '_CRT_SECURE_NO_WARNINGS' ] )
env.Append( CPPDEFINES='MSVC_DLL' )
env.Append( LIBS = 'WS2_32' )
env.AppendUnique( LINKFLAGS=['-Wl,-subsystem,windows'] )

if int( debug ):
    env.Append( CCFLAGS='/Od /RTC1 /MDd /Gy /Zi', LINKFLAGS='/DEBUG' )
else:
    env.Append( CCFLAGS='/O2 /Oi /GL /MD', LINKFLAGS='/LTCG')`

Solution

  • Sorry guys. I've made a mistake. Wl, is just for supress warnings; Like you said: it's just to insert env.Append(LINKFLAGS=['/Wl', '/SUBSYSTEM:WINDOWS']) in the SConstruct. I've made a very dummy mistake. In the main.cpp I forgot to do a simple verification of if I running my software on a console or on a windowed app. Just a simple #ifdef WIN32_LEAN_AND_MEAN

    thanks for you support.