Reputation: 4251
I've a file called AquaMain.cpp
#include "AquaGame.h"
using namespace Aqua;
#ifdef _WIN32
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
AquaGame::get()->init();
return AquaGame::get()->run();
}
#endif
This file is inside a static lib.
When I try to compile a project that uses this static lib the build fails with this error
1>MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol WinMain@16 referenced in function __tmainCRTStartup
The file AquaMain.cpp is not being compiled I don't know why...
If I move the WinMain function to the executable project the function is compiled and everything works, but I would like WinMain to be in the static lib.
Any ideas?
Upvotes: 0
Views: 165
Reputation: 4251
Even though AquaMain.cpp had the extension .cpp Visual Studio 2012 has using it as a header because AquaMain.cpp Property Pages had the "Item Type" field set to C/C++ header.
Changing the field to C/C++ compiler fixed the error.
Upvotes: 0
Reputation:
you need to declare your WinMain as extern "C"
extern "C" int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
AquaGame::get()->init();
return AquaGame::get()->run();
}
Upvotes: 1