I don’t know if this error has been fixed in CMake. I am using VC ++ 2010 express and CMake v2.8.10.1 (which is currently the latest version) and I still have the same problem.
A working solution was provided here : change the source code (e.g. main.cpp / main.c) by adding:
#ifndef NDEBUG #pragma comment(linker, "/SUBSYSTEM:CONSOLE") #endif
Alternatively, you can add the linker flag “/ SUBSYSTEM: WINDOWS” to the release mode assembly. I am using this definition, which seems to work:
#ifdef _MSC_VER # ifdef NDEBUG # pragma comment(linker, "/SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup") # else # pragma comment(linker, "/SUBSYSTEM:CONSOLE") # endif #endif
Use the entry point parameter to avoid linker errors if you specify:
int main(int argc, char* argv[]) { ... }
source share