I'm trying to use SFML to make a game, but I ran into an error. I have 4 files in my project: main.cpp, Screen.cpp, Screen.h, and GameState.h. I built them individually and the only one with an error is Screen.cpp. The error reads "undefined reference to `WinMain@16'". Here's my code:
Seems that your build is expecting screen.cpp to be turned into a stand-alone windows executable program. I'm guessing that's not what you want.
Make sure your project is whatever Visual Studio uses these days to mean a console program with a regular, simple int main() entry point. Building them separately is flawed - they need to be linked together to make the complete, working program, and if you don't know how to take object files and manually link them together to make a single executable, you're creating more work for yourself. Put them into the project and have VS build them for you.
@Moschops: Oh, I guess that's because I built it individually to troubleshoot. Originally the error was "undefined reference to 'Screen::showSplash(sf::RenderWindow&)'", and I wanted to see if I made a mistake in Screen.cpp. I call it like this:
1 2 3 4 5 6 7 8 9 10 11
Screen screen;
switch(gameState)
{
case ShowingSplash:
screen.showSplash(mainWnd);
break;
case Playing:
mainWnd.Clear(Color(255, 255, 255));
mainWnd.Display();
break;
}
I couldn't find any reason for why that would give me an error, so I built Screen.cpp individually.