2

I have a console application in Qt, which I would like to execute in Visual Studio, so I can use it's profiler.

I'm using a plugin called Qt VS Tool, which seems to have imported the project correctly. I can also create a new Qt project and it works fine.

However on this application that I imported, VS seems to be searching for a WinMain function as entry point instead of main, even if the "SubSystem" is set to Console (/SUBSYSTEM:CONSOLE) in Configuration Properties -> Linker -> System -> SubSystem.

I am getting this error:

LNK2019 unresolved external symbol WinMain referenced in function __tmainCRTStartup

If I manually change the entry point to "main", in Configuration Properties -> Linker -> Advanced -> Entry Point, the application starts, but argc and argv contain trash. It seems that is not possible to pass arguments when specifying an entry point.

How can I make it work properly with int main(int argc, char *argv[]) ?

I'm using VS 2015 Community with MSVC 11 compiler (VS 2012) due to a library.

Community
  • 1
  • 1
mathiasfk
  • 1,278
  • 1
  • 19
  • 38

1 Answers1

1

The solution I found is to set the entry point to mainCRTStartup in Configuration Properties -> Linker -> Advanced -> Entry Point. The difference between main and mainCRTStartup is discussed here.

Doing that, the arguments are passed correctly to the main function.

Community
  • 1
  • 1
mathiasfk
  • 1,278
  • 1
  • 19
  • 38