0

I've a cross platform app (it's a basic ellipsoid drawing example using Qt).It compiles and I can execute it form a command prompt. For linux I know how to create a .desktop file so I can launch the app that does not show a terminal when it is launched. However on windows, when I double click on the exe file in the explorer, it does not only luanches the Qt gui that I coded, but also a cmd window. Is there a way in windows to prevent the application to open this cmd window when I dobule click it on the explorer?

In windows I set up the project using cmake-gui and then I open the generated visual studio solution and compile it using microsoft visual studio 2019

apalomer
  • 1,895
  • 14
  • 36
  • There should be a compiler flag in MSVC somewhere for. Something like application type, where you could select console application and GUI application (the latter has another name, but cannot remember). Have you tried using [`WinMain`](https://learn.microsoft.com/en-us/windows/desktop/api/winbase/nf-winbase-winmain) function instead of standard `main` function? I usually don't encourage it (try MSVC project settings first), because it is *non-standard*, but if it does the trick for you... – Aconcagua May 22 '19 at 08:35
  • `set_target_properties(your_executable_target PROPERTIES WIN32_EXECUTABLE TRUE)` is the command in CMake to rather select the WinMain function instead of the main function as entry point. – vre May 22 '19 at 09:47
  • Is this a property that beahaves properly in unix as well? The real app that I am working on has to be crossplatform. – apalomer May 22 '19 at 09:49
  • Yes I think it does. The documentation does not state otherwise that its use is restricted to windows. – vre May 22 '19 at 10:10

1 Answers1

0

I've solved this issue with this previous post hint. I added some lines in my final cpp file where the main is created has been modified to:

//... all includes and other things previous to main function
#ifdef _WIN32
  #pragma comment(linker, "/SUBSYSTEM:windows /ENTRY:mainCRTStartup")
#endif
int main(int argc, char** argv)
{//... rest of code
apalomer
  • 1,895
  • 14
  • 36