I started my Visual Studio project as a windows application, however I’ve come to realize that if I want to use GLFW then I’m supposed to open a GLFW window instead of a standard wWinMain window. I have a wWinMain function but since it kept running every time I ran the program instead of my int main() function with the GLFW window test code inside, I changed the name of the wWinMain function in the hopes that when building the program it would defer to the main() function I wrote. However it hasn’t worked and instead I keep getting the same error:
error LNK2019: unresolved external symbol WinMain referenced in function "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ)
How do I get it to stop looking for the wWinMain function and just run the main() one instead?
The only solution that has worked so far is to rename my main() function to wWinMain and have it accept all the variables but do nothing with them and just run my code as normal inside, however this doesn’t seem optimal.
I’ve also tried the answer suggested here but that always opens a command window with the GLFW window whereas with the wWinMain function by default would run without one except when I specifically used AllocConsole(), so I suspect the answer suggested there isn’t actually the correct solution for my issue.
Ive also tried the solution shown here but that just doesn’t work for me? idk maybe I’m implementing it wrong
>Solution :
Windows knows two types of program that are relevant to you: Console and graphical.
Console programs automatically get a console (and you can get their output in a command line, for example) and their entry point is main or wmain.
Graphical programs don’t get a console automatically, which is what you want. They don’t automatically create any windows either; you’ll have to do that manually (i.e. with GLFW like you want to). Their entry point is always WinMain or wWinMain.
You’ll have to choose one, you can’t mix-and-match. Just put your GLFW code in wWinMain. main is meaningless in a graphical Windows program, you should remove it. There’s nothing wrong with not using the parameters passed to wWinMain – if you don’t need them, that’s fine. main also takes parameters that you don’t currently use (but main is a little special since you can omit the unused parameters).