Visual Studio 2022 unresolved symbol to WinMain function

While using Visual Studio 2022 to build a Juce GUI app, I receive an unresolved external symbol error to WinMain.

I receive this error in both debug and release builds.

Sources online told me to change the linker subsystem to Console. I did not want to do this since I want a GUI app, yet when I do it, it does not fix anything anyway. I get an unresolved symbol to a regular main function.

Does anyone know why this issue might be occuring?

Have you changed the “Project Type” in Projucer? That isn’t supported well, since the template code generated by Projucer when creating a new project doesn’t follow the Project Type change. You should make a new project and make sure to select the right project type from the beginning. I hope this helps.

1 Like

No, the project has always been a GUI application. Sometimes if I delete the builds then start by running through debugger in Debug mode I can get it working. All seems very unusual

Just an update with some more info.

I attempted to create a new GUI project which did not encounter the same issues. I am using JUCE 6.1.6. The project is a large GUI application. It has a few dependancies in the form of static and dynamic libraries. The project fully builds and runs in xcode on macOS. The problem here does not seem to happen all the time, however it does happen a lot. I have checked that it is not an anti-virus causing the problem. Are there any other things I can do to narrow it down?

When this error comes, does “Build” → “Clean Solution” help build it the next time?

Unfortunately not, I have tried that and deleting the build files from the x64 folder in the solution directory

I think the only way of digging into this is to make the new project successively more like the existing project. At some point you’ll run into the issue and that will allow us to identify the cause.

Issue has been solved. The problem was an external header only library that contained a main.cpp file. This meant 2 main.objs were being created which Visual Studio did not want to do so it only created the first one (the external library one). This meant the proper main.cpp was skipped and so the winmain function was never found. For some reason this was only an issue in Visual Studio and not in Xcode