Reputation:
I wanted to create an new c++ project and start coding. I am working in an existing solution with 30+ projects in it. So instead of main() GwMain(..) is used. This works for all other files but not when I create a new c++ project. I get a linker error:
LNK2019 unresolved external symbol _main referenced in function "int__cdel invoke_main(void)" (?invoke_main@@YAHXZ)
File: MSVCRTD.lib(exe_main.obj)
I checked already this: Linker->System->SubSystem -> Windows.
And when I change it from console to windows it shows this:
LNK2019 unresolved external symbol _WinMain referenced in function "int__cdel invoke_main(void)" (?invoke_main@@YAHXZ)
The code is just like this:
#include <gwcore.hpp>
#include <gw.hpp>
int GwMain(int, char**)
{
return 0;
}
Grit is used here a very old framework.
Upvotes: 0
Views: 1919
Reputation: 1368
After checking all the compilation and linking options with other projects that work fine.
From your solution, select a project that works (and that uses GwMain). Right button-> property and check its dependencies in "common properties":
Do this manipulation on the other projects that work correctly (and that use GwMain) and try to see if there is a common dependency which allows them to use GwMain, then, try to add this dependency to your project that does not work
Upvotes: 0
Reputation: 456
Please check Project > Properties > General > Project Defaults > Configuration Type.
If this is ".exe" then a main is needed for this project. Else if this is ".dll" or ".lib" your code should compile.
Upvotes: 0