Effects of switching between /SUBSYSTEM:CONSOLE to /SUBSYSTEM:WINDOWS in a DLL - visual-studio

I couldn't find anything useful on the MSDN for this case. Using Dependency Walker, in the module list, I see a mixed usage of Console and GUI.
Does this have an impact when compiling a DLL?

This option only has an effect on applications (exe), not on libraries(dll).
Its documentation says:
The /SUBSYSTEM option specifies the environment for the executable.
The choice of subsystem affects the entry point symbol (or entry point
function) that the linker will select.
This does not affect libraries, which have their own (optional) entry point.
Additional information following CyberShadow's comment: The subsystem field itself seems to be ignored when a DLL is loaded. This article about CSRSS says (emphasis mine):
Furthermore, each process is associated with one, certain subsystem;
this property is being set by the linker (during the compilation
process), and resides in the following PE structure field: [...]

My below reply is just some findings.
I tried to create below types of project within VS2015:
Win32 console app project
Win32 DLL project
Win32 Windows app project
Below are their complete linking options:
Win32 console app project
/OUT:"C:\Temp\ConsoleApplication3\Debug\ConsoleApplication3.exe"
/MANIFEST /NXCOMPAT
/PDB:"C:\Temp\ConsoleApplication3\Debug\ConsoleApplication3.pdb"
/DYNAMICBASE "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib"
"comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib"
"uuid.lib" "odbc32.lib" "odbccp32.lib" /DEBUG /MACHINE:X86
/INCREMENTAL
/PGD:"C:\Temp\ConsoleApplication3\Debug\ConsoleApplication3.pgd"
/SUBSYSTEM:CONSOLE /MANIFESTUAC:"level='asInvoker' uiAccess='false'"
/ManifestFile:"Debug\ConsoleApplication3.exe.intermediate.manifest"
/ERRORREPORT:PROMPT /NOLOGO /TLBID:1
Win32 DLL project
/OUT:"C:\Temp\ConsoleApplication3\Debug\Win32DLLProject1.dll"
/MANIFEST /NXCOMPAT
/PDB:"C:\Temp\ConsoleApplication3\Debug\Win32DLLProject1.pdb"
/DYNAMICBASE "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib"
"comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib"
"uuid.lib" "odbc32.lib" "odbccp32.lib"
/IMPLIB:"C:\Temp\ConsoleApplication3\Debug\Win32DLLProject1.lib"
/DEBUG /DLL /MACHINE:X86 /INCREMENTAL
/PGD:"C:\Temp\ConsoleApplication3\Debug\Win32DLLProject1.pgd"
/SUBSYSTEM:WINDOWS /MANIFESTUAC:"level='asInvoker' uiAccess='false'"
/ManifestFile:"Debug\Win32DLLProject1.dll.intermediate.manifest"
/ERRORREPORT:PROMPT /NOLOGO /TLBID:1
Win32 Windows app project
/OUT:"C:\Temp\ConsoleApplication3\Debug\Win32WindowsProject1.exe"
/MANIFEST /NXCOMPAT
/PDB:"C:\Temp\ConsoleApplication3\Debug\Win32WindowsProject1.pdb"
/DYNAMICBASE "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib"
"comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib"
"uuid.lib" "odbc32.lib" "odbccp32.lib" /DEBUG /MACHINE:X86
/INCREMENTAL
/PGD:"C:\Temp\ConsoleApplication3\Debug\Win32WindowsProject1.pgd"
/SUBSYSTEM:WINDOWS /MANIFESTUAC:"level='asInvoker' uiAccess='false'"
/ManifestFile:"Debug\Win32WindowsProject1.exe.intermediate.manifest"
/ERRORREPORT:PROMPT /NOLOGO /TLBID:1
So we can see, for a /DLL, /SUBSYSTEM:WINDOWS is defined.
Then I tried to build a DLL with 3 different SUBSYSTEM values:
CONSOLE
WINDOWS
NOT SET
There are other values as well, but I can only build successfully with the above 3. Other values will lead to linking errors, which means some external symbols are needed.
The full list of possible SUBSYSTEM values is:
You can use the CFF Explorer to inspect the PE/COFF binaries.
The SUBSYSTEM header field locates at the file offset 0x14C of a PE/COFF file. It is part of the Optional Header.
/DLL /SUBSYESTEM:CONSOLE
/DLL /SUBSYESTEM:WINDOWS
/DLL and no /SUBSYESTEM option (by selecting NOT SET in VS2015 project properties page
Interestingly, the NOT SET and WINDOWS values lead to the same content in the binary header.
And I compared the whole binary of the 3 DLLs. It seems the rest of the binaries are all the same, except for some timestamp and debug info.
This is just some fact I found. How /SUBSYSTEM option affects the binary behavior depends on how the loader interprets this field.
In one of the projects I participated in, the /SUBSYSTEM:CONSOLE and /DLL are used together, which is different from the default combination for a DLL project. But it seems nothing bad happens. So I agree with #Frédéric Hamidi that this flag has no functional impact to a DLL.

Related

Long building time with release configuration. is it normal?

I use the latest Intel compiler atop MVS 2013. I am developing a small application which currently consists of a static library with main functionality (9 classes) and an one-file console executable to test the former. I decided to build the application under release configuration to find out how faster it will become.
The problem is while the static library builds rather swiftly producing 13 MB .lib file (that is,as I found out, normal), the executable is taking very long time. I left it overnight and it is still hasn't been finished (currently over 12 hours). There has been no visible progress except mcpcom has been slowly increasing its memory usage to currently 1GB.
The static library compiling settings :
/MP /GS /GA /W3 /Gy /Zc:wchar_t /Zi /O2 /Fd"Release\vc120.pdb" /Qvec-report1 /D "WIN32" /D "NDEBUG" /D "_LIB" /D "_UNICODE" /D "UNICODE" /Qstd=c++11 /Qipo /Zc:forScope /Gd /Oi /MD /Fa"Release\" /EHsc /nologo /Fo"Release\" /Fp"Release\MyApplication_library.pch"
The executable compiling options:
/MP /GS /GA /W3 /Gy /Zc:wchar_t /I"C:\Work\MyApplication\MyApplication_library" /Zi /O2 /Fd"Release\vc120.pdb" /Qvec-report1 /D "_UNICODE" /D "UNICODE" /Qstd=c++11 /Qipo /Zc:forScope /Gd /Oi /MT /Fa"Release\" /EHsc /nologo /Fo"Release\" /Fp"Release\MyApplication_test.pch"
linker options
/OUT:"C:\Work\MyApplication\Release\MyApplication_test.exe" /MANIFEST /NXCOMPAT /PDB:"C:\Work\MyApplication\Release\MyApplication _test.pdb" /DYNAMICBASE "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" "C:\Work\Speedsim30\Release\MyApplication_Controller.lib" /LTCG:STATUS /MACHINE:X86 /OPT:REF /SAFESEH /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /ManifestFile:"Release\MyApplication_test.exe.intermediate.manifest" /OPT:ICF /NOLOGO /TLBID:1
My personal computer has a powerful hardware configuration with Intel i7-4770K, 8 GB of DDR3-2133, and 2 SSDs in RAID0
thank you in advance
I found out that the problem is in in /MT and /MD mismatch between the library and the executable - i must have misclicked while setting up the release configuration. Correcting it allowed application to build.

Is this a bug in Visual Studio 2012 linker when using /manifest:embed?

I've noticed a small program is taking ~15ms longer to invoke when compiled with vs2012 than it took in 2010. This does not seem like much, but it can be called numerous times and we are seeing a ~2x slowdown in certain functionality due to this extra 15ms.
I have found a workaround which I document below, but my question is if this is something that I'm doing wrong, or if I'm seeing a bug in the way Visual Studio 2012 has implemented the /MANIFEST:embed option. Sorry for the length of what follows, but I find it difficult to be both thorough and brief at the same time.
About my environment:
Windows 7 Enterprise x64 + Service Pack 1
c:\tmp>cl
Microsoft (R) C/C++ Optimizing Compiler Version 17.00.60610.1 for x86
Copyright (C) Microsoft Corporation. All rights reserved.
usage: cl [ option... ] filename... [ /link linkoption... ]
c:\tmp>mt
Microsoft (R) Manifest Tool version 6.2.9200.16384
Copyright (c) Microsoft Corporation 2012.
All rights reserved.
I can reproduce by starting a new empty project console application. A single source file with this simple code:
#include <iostream>
#include <string>
int main()
{
std::string buf;
while(std::cin >> buf)
{
std::cout << buf;
buf="";
}
}
When this is compiled by VS, it issues effectively this (I've taken the actual full-path commands from vs and cleaned them up so you can issue these from a VS2012 developer command prompt)-- take the above code and save as test.cpp, then in the same directory from a Developer Command Prompt For VS 2012 window, issue:
CL.exe /c /Zi /nologo /W3 /WX- /sdl /O2 /Oi /Oy- /GL /D WIN32 /D NDEBUG /D _CONSOLE /D _UNICODE /D UNICODE /Gm- /EHsc /MD /GS /Gy /fp:precise /Zc:wchar_t /Zc:forScope /Fd"test.pdb" /Gd /TP /analyze- /errorReport:prompt test.cpp
link.exe /ERRORREPORT:PROMPT /OUT:test.exe /INCREMENTAL:NO /NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /DEBUG /PDB:"test.pdb" /SUBSYSTEM:CONSOLE /OPT:REF /OPT:ICF /LTCG /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"test.lib" /MACHINE:X86 /SAFESEH test.obj
If you now view the resulting test.exe with notepad, you can see that the embedded manifest is this:
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level='asInvoker' uiAccess='false' />
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
If I write a bat file with this line repeated 100 times:
echo "Hello" | test.exe
and execute it, it takes approximately 4.5s on my system (I used cygwin time to determine this)
$ time ./test.bat
"Hello""Hello""Hell
o""Hello""Hello""He
llo""Hello""Hello""
real 0m4.523s
user 0m0.015s
sys 0m0.015s
Now if I omit /MANIFEST:embed from my link line, instead I will get test.exe.manifest automatically generated
link.exe /ERRORREPORT:PROMPT /OUT:test.exe /INCREMENTAL:NO /NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"test.pdb" /SUBSYSTEM:CONSOLE /OPT:REF /OPT:ICF /LTCG /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"test.lib" /MACHINE:X86 /SAFESEH test.obj
This is how VS2010 built the tool before migration. Using the above line, the resulting test.exe.manifest is:
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level='asInvoker' uiAccess='false' />
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
This appears the same as what was embedded in the exe file according to the first link command I offered. Of course after the above link command, there is no manifest file embedded which I can confirm by viewing my test.exe in notepad. I can now embed the test.exe.manifest file just generated with
mt.exe -outputresource:test.exe;#1 -manifest test.exe.manifest
And now, if I look at the test.exe in notepad, I see a slightly different formulation of the requestedExecutionLevel line-- it now has what looks to me a more proper termination. I'm no expert at xml but I'm used to seeing <key></key> pairs, not <key... \> which may well be a valid syntax too.
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
And now timing the 100 call bat file runs about 1.5s faster
$ time ./test.bat
"Hello""Hello""Hell
o""Hello""Hello""He
llo""Hello""Hello""
real 0m3.095s
user 0m0.015s
sys 0m0.000s
So is this a bug with the way the manifest file is generated with the <requestedExecutionLevel level=.... \> instead of <requestedExecutionLevel level=... ></requestedExecutionLevel>???
Or something with the way mt.exe embeds what appears to be the exact same manifest??
I was able to build the test.exe the faster way from visual studio by setting property 'Embed Manifest' to 'No' on 'Manifest Tool'>'Input and Output' sheet. I then set 'Additional Manifest Files' to $(IntDir)$(TargetName)$(TargetExt).intermediate.manifest (same value copied from Linker > Manifest File > 'Manifest File'). I insured 'Output Manifest File' was blank and on the 'Manifest Tool' > 'All Options' sheet, I set 'Additional Options' to /outputresource:"$(TargetDir)$(TargetName)$(TargetExt);#1"
But we use CMAKE for our build system and I was unable to find a magic incantation to do that from CMAKE.
I tried using mt.exe to extract and re-embed, but the embedded version doesn't seem to change. If I edit the extracted, then embedding embeds the faster running version, but then I have to edit once to change it, and edit again to put it to what it should be. So I wound up creating a dummy.manifest file with no UAC options.
dummy.manifest:
?<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
</trustInfo>
</assembly>
Then the following custom command can correct the issue:
IF(WIN32)
ADD_CUSTOM_COMMAND(TARGET test
POST_BUILD
COMMAND "mt.exe" "-inputresource:\"$(TargetDir)\\$(TargetFileName);#1\" -out:\"${CMAKE_CURRENT_BINARY_DIR}/$(TargetFileName).fix.manifest\""
COMMAND "mt.exe" "-outputresource:\"$(TargetDir)\\$(TargetFileName);#1\" -manifest \"${CMAKE_CURRENT_SOURCE_DIR}/dummy.manifest\""
COMMAND "mt.exe" "-outputresource:\"$(TargetDir)\\$(TargetFileName);#1\" -manifest \"${CMAKE_CURRENT_BINARY_DIR}/$(TargetFileName).fix.manifest\""
COMMENT "Fixing bad manifest file"
)
ENDIF(WIN32)
So I have a solution in place that is a bit ugly.
It just seems to me that the odd manifest causes some sort of internal error that takes an extra 15ms on my system to resolve. If this is true, it seems like a bug in the /MANIFEST:embed option in that it doesn't do what 2010's 2 step embedding did with mt.exe.

Avoid mspdbsrv when compiling in Visual Studio (2008)

When two visual studio processes compile in parallel, the second will reuse the instance of mspdbsrv started by the first one. So when the first build is terminated and the whole process tree terminated (e.g. by Jenkins), the other build fails.
That bug report describes how to start it manually so it does not get killed. But the thing is also famous for occasionally forgetting to close files, which can fail the next build.
Is there a combination of options under which mspdbsrv would not be used at all?
Ok, I am looking for a generic answer, so I didn't include the current options at first. But the answer so far sounds like mspdbsrv shouldn't be used when some options are not used. Except in the trivial test project used (by CMake) to check whether MSC++ works they are not used, yet it does start mspdbsrv.exe. The trivial projects is a .vcproj file, compiled via devenv.com CompilerIdC.vcproj /build Debug. The build runs following commands for C:
cl.exe /Od /D "_UNICODE" /D "UNICODE" /FD /EHsc /RTC1 /MDd /Fo"Debug\\" /Fd"Debug\vc90.pdb" /W0 /c /TC ".\CMakeCCompilerId.c"
link.exe /OUT:".\CompilerIdC.exe" /INCREMENTAL:NO /MANIFEST /MANIFESTFILE:"Debug\CompilerIdC.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /NODEFAULTLIB:"libc" /SUBSYSTEM:CONSOLE /DYNAMICBASE /NXCOMPAT kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ".\Debug\CMakeCCompilerId.obj"
mt.exe /outputresource:".\CompilerIdC.exe;#1" /manifest ".\Debug\CompilerIdC.exe.intermediate.manifest"
and following commands for C++:
cl.exe /Od /D "_UNICODE" /D "UNICODE" /FD /EHsc /RTC1 /MDd /Fo"Debug\\" /Fd"Debug\vc90.pdb" /W0 /c /TP ".\CMakeCXXCompilerId.cpp"
link.exe /OUT:".\CompilerIdCXX.exe" /INCREMENTAL:NO /MANIFEST /MANIFESTFILE:"Debug\CompilerIdCXX.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /NODEFAULTLIB:"libc" /SUBSYSTEM:CONSOLE /DYNAMICBASE /NXCOMPAT kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ".\Debug\CMakeCXXCompilerId.obj"
mt.exe /outputresource:".\CompilerIdCXX.exe;#1" /manifest ".\Debug\CompilerIdCXX.exe.intermediate.manifest"
This still starts the mspdbsrv.exe. I actually used the fact that it does to protect it from Jenkins killer for the time being.
The option /FD is injected by devenv.com. I've tried to run it via msbuild, but that invokes vcbuild (Visual Studio 2008) and that executes the same commands including the /FD option. And the WinCE targets are only supported by the Visual Studio generators in CMake, so I can't switch to make easily.
This is not a common complaint, there's no existing feedback report for it on connect.microsoft.com. Otherwise the recommended way to accelerate resolution of problems like this, you do get a Microsoft engineer to look at the issue.
And no, there is no specific option to disable mspdbsrv.exe. There is only one for the opposite, to enable it. The /FS option forces the compiler to use it.
Strong hints that you are using a compiler option that's not commonly used on build machines. You did not document anything so guessing is required. The number one candidate is the /MP option. Which always requires the compiler to use mspdbsrv.exe since it will launch the compiler multiple times, each working on one of the source files that were passed. A scenario where mspdbsrv.exe is required since each compiler instance is likely to want to write to the same .pdb file, particularly the program database specified in the /Fd option.
So look at your build scripts and remove /MP if you see it. Document the options you pass to the compiler next. Filing a feedback report at connect.microsoft.com is strongly recommended.
After update: your build server is using the /FD option incorrectly. The MSDN Library article has this to say about it:
/FD is only used by the development environment, and it should not be used from the command line or a build script.
I cannot predict what effect it has on mspdbsrv.exe, it very likely has one since /FS is strongly linked to /Gm which is strongly linked to /FD. Removing the option is the obvious next step.
I am sure you must already have tried setting "Generate Debug Info" -> No
Not sure if below came to your mind or not:
Try removing (or rename or move to other location) mspdbsrv.exe and related dlls (mspdb80.dll and mspdbcore.dll) and then see what happens.
This is just a wild guess but worth trying.

MSVC2008 c/c++ console application spawns new console

Where does an application decide/cause to spawn a new console window (when linking dynamically)?
Is there some define or pragma I may have overlooked or some change in standard behavior in the default runtime dlls? I don't feel very sure these are the right question to ask, please read the Background below and bear with me. I'm glad for every nudge in the right direction.
Background:
A console application (/SUBSYSTEM:CONSOLE) spawns a new daughter-console when started. Other applications using the same sources and configuration setup don't. The only difference (seemingly) are the provided 3rd-party-dlls. Because of the new sub-console, I cannot redirect the output anymore (app.exe > dump.txt). Redirection is vital for this application.
I'm building that c/c++ console application on MS Visual Studio 2008. The application links dynamically to an awful messy lot of dlls. The whole Library-pack is provided by one 3rd party as release build with no debug info. The dll-pack includes, among others, msvcr90.dll (9.0.30729.1) msvcp90.dll (9.0.30729.1) and msvcr80.dll (8.0.50727.42).
Whatever causes this seem to be very global, since the first fprintf to stdout or stderr in main() goes to the new console window, not to the shell where the application was started.
In my first tries, I built the Application on Visual Studio 2005 (which we used until the latest version of the library package) and 2010 (which is recommended by the dll-provider). Those builds didn't spawn consoles but did crash when memory was freed that probably was allocated in a different version of the runtime. Using Dependency Walker I could find the "main" runtime the dlls were linked against.
PS: Afaik linking against 2 different runtimes is dangerous enough. But it is an improvement over the previous version of the dll-pack, which included the r, c and m variants of 71, 80, 90 runtime dlls.
PPS: I mainly developed on linux before, so I could have made some very basic mistakes. Please accept my apologies for my ignorance in advance.
Update 1:
Following Anton Kovalenko's advice, I chipped more and more libraries away. Then I removed more code. Finally I ended with:
#include <stdio.h>
#include <Windows.h>
int main(int _argc, char **_argv)
{
printf("application running ...\n");
fflush(stdout);
Sleep(2000);
exit(0);
}
Configuration Properties > c/c++ > Command Line:
/Od /Ob2 /D "_MBCS" /FD /EHsc /MD /Fo"a4input_interface_6.12_1.dir\Release\\" /Fd"a4input_interface_6.12_1.dir\Release\vc90.pdb" /W3 /nologo /c /TC /errorReport:prompt
Configuration Properties > Linker > Command Line:
/OUT:"D:\sascha\svn\a4_devel\cmakebuild\build\win32_release\inputinterfaces\.inter_612_1_32.exe" /VERSION:0.0 /INCREMENTAL:NO /NOLOGO /MANIFEST /MANIFESTFILE:"a4input_interface_6.12_1.dir\Release\.inter_612_1_32.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /SUBSYSTEM:CONSOLE /DYNAMICBASE:NO /ERRORREPORT:PROMPT kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib
Configuration Properties > Manifest Tool > Command Line
/nologo /outputresource:"..\..\..\build\win32_release\inputinterfaces\.inter_612_1_32.exe;#1"
I still have the problem, that a shell is spawned and stdout cannot be redirected using (i.e. app.exe > test.txt). So the text "application running ..." isn't printed on the same shell where the exe is started.
I'm still clueless and still grateful for every hint.
Update 2:
I created a batch-file for the command lines. If I compile it with that, the exe works as intended.
cl.exe /Od /Ob2 /D "_MBCS" /FD /EHsc /MD /Fo"a4input_interface_6.12_1.dir\Release\\" /Fd"a4input_interface_6.12_1.dir\Release\vc90.pdb" /W3 /nologo /c /TC /errorReport:prompt main.c
link.exe /OUT:"D:\sascha\svn\a4_devel\cmakebuild\build\win32_release\inputinterfaces\.inter_612_1_32.exe" /VERSION:0.0 /INCREMENTAL:NO /NOLOGO /MANIFEST /MANIFESTFILE:"a4input_interface_6.12_1.dir\Release\.inter_612_1_32.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /SUBSYSTEM:CONSOLE /DYNAMICBASE:NO /ERRORREPORT:PROMPT kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib a4input_interface_6.12_1.dir\Release\main.obj
mt.exe /manifest a4input_interface_6.12_1.dir\Release\.inter_612_1_32.exe.intermediate.manifest /nologo /outputresource:"D:\sascha\svn\a4_devel\cmakebuild\build\win32_release\inputinterfaces\.inter_612_1_32.exe";#1"
So there is something visual studio does that isn't reflected in the Command Line it gives. What and why?
I'm still clueless and still grateful for every hint.
Solution:
There was a debugger configured for this name of executable. That's why I had this behavior:
inter_612_2_32.exe no sub shell
intes_612_2_32.exe no sub shell
inter_612_1_32.exe spawns sub shell
intes_612_1_32.exe no sub shell
Using ProcessExplorer I found out, that inter_612_1_32.exe is a sub process of DbgHost.exe. Unfortunately I didn't follow that lead and forgot about it.
The loaded Dlls actually didn't matter. The problem was an entry in the Registry in:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\inter_612_1_32.exe
I guess the entry was created by DebugDiag, Application Verifier or some other tool but not removed when deleted in the tool's GUI.
Thanks to everyone who thought about it.
Some of third-party dlls may be calling FreeConsole and AllocConsole, which have the effect you describe. If it's done within DllMain for DLL_PROCESS_ATTACH, it will happen before entering main() for libraries which are your project dependencies.
There seems to be no alternative explanation related to your build environment.
You can learn more if you create a project which will use LoadLibrary for suspected dlls instead of linking against their import libraries: if some of them (or their dependencies) does FreeConsole and AllocConsole in DllMain, it will happen during LoadLibrary call.

::LookupAccountSid API Extremely Slow When Targeting x64 Platform (Windows 7)

During our application startup, we are making a call to ::LookupAccountSid(). When I build targeting the x86 architecture, this call is nearly instantaneous. However, when I target x64 (debug or release), the call generally takes over 40s to complete. Since this is occurring during application startup, the result is fairly unpleasant as it will appear to the user that the application is not launching.
I am running Windows 7 Professional 64-bit on a Dell Studio XPS 16 (Intel Core i7 Q 720).
Our application is a native Windows application written in C++.
My compiler options (CCOPTS) and linker options (LINKOPTS) are as follows:
CCOPTS = "/nologo /Gz /W3 /EHs /c
/DWIN32 /D_MBCS /Ob1 /vmg /vmv /Zi /MD
/DNDEBUG /DDV_BUILD_DLL /DIV_BUILD_DLL
/DDVASSERT_EXCEPTION /Zc:wchar_t-"
LINKOPTS = "/manifest:no /nologo
/machine:X64 kernel32.lib user32.lib
gdi32.lib winspool.lib comdlg32.lib
advapi32.lib shell32.lib ole32.lib
oleaut32.lib uuid.lib odbc32.lib
odbccp32.lib /DEBUG
/subsystem:windows /DLL"
Any help would be greatly appreciated :D
These kind of long delays are almost always network related. This blog post shows a troubleshooting strategy.

Resources