mathiasfk
mathiasfk

Reputation: 1290

Qt aplication in Visual Studio - entry point

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.

Upvotes: 2

Views: 631

Answers (1)

mathiasfk
mathiasfk

Reputation: 1290

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.

Upvotes: 1

Related Questions