Hey,
I am new here and want to learn SFML. I installed SFML 2.6.1 Visual C++ 15 (2017) - 32-bit and Visual Studio 2022. I have completed SFML and Visual Studio tutorial and ended with a beautiful window with a green circle! So I thought I can move to another project from this book "Beginning C++ Game Programming - Second Edition". I have finished the first chapter, run the project with the same properties as before and get this error:
Build started at 1:00 PM...
1>------ Build started: Project: SpaceInvaders, Configuration: Debug Win32 ------
1>GameScreen.obj : error LNK2001: unresolved external symbol "public: static int WorldState::WORLD_HEIGHT" (?WORLD_HEIGHT@WorldState@@2HA)
1>GameScreen.obj : error LNK2001: unresolved external symbol "public: static int WorldState::SCORE" (?SCORE@WorldState@@2HA)
1>GameUIPanel.obj : error LNK2001: unresolved external symbol "public: static int WorldState::SCORE" (?SCORE@WorldState@@2HA)
1>GameScreen.obj : error LNK2001: unresolved external symbol "public: static int WorldState::LIVES" (?LIVES@WorldState@@2HA)
1>GameUIPanel.obj : error LNK2001: unresolved external symbol "public: static int WorldState::LIVES" (?LIVES@WorldState@@2HA)
1>GameScreen.obj : error LNK2001: unresolved external symbol "public: static int WorldState::NUM_INVADERS_AT_START" (?NUM_INVADERS_AT_START@WorldState@@2HA)
1>GameScreen.obj : error LNK2001: unresolved external symbol "public: static int WorldState::NUM_INVADERS" (?NUM_INVADERS@WorldState@@2HA)
1>C:\VSProjects\SpaceInvaders\Debug\SpaceInvaders.exe : fatal error LNK1120: 5 unresolved externals
1>Done building project "SpaceInvaders.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
========== Build completed at 1:00 PM and took 00.300 seconds ==========
I guess it has something to do with this file:
#pragma once
class WorldState {
public:
static const int WORLD_WIDTH = 100;
static int WORLD_HEIGHT;
static int SCORE;
static int LIVES;
static int NUM_INVADERS_AT_START;
static int NUM_INVADERS;
static int WAVE_NUMBER;
};
I attach some useful screenshots.
Not sure if that's the correct way to do it but I copied "include" and "lib" dirs from SFML to my SolutionDir (as you can see in the screenshots)