SFML community forums

Help => General => Topic started by: Trigonaut on January 02, 2021, 06:19:37 am

Title: Unresolved external symbol error
Post by: Trigonaut on January 02, 2021, 06:19:37 am
I am getting

main.obj : error LNK2001: unresolved external symbol "public: static class sf::RenderTexture GameRenderer::render

When running in visual studio.

I have followed the tutorial for setting up with visual studio.

These are my linker additional dependencies:
sfml-graphics-s.lib;sfml-window-s.lib;sfml-system-s.lib;sfml-audio-s.lib;opengl32.lib;freetype.lib;winmm.lib;gdi32.lib;openal32.lib;flac.lib;vorbisenc.lib;vorbisfile.lib;vorbis.lib;ogg.lib;
for release and
sfml-graphics-s-d.lib;sfml-window-s-d.lib;sfml-system-s-d.lib;sfml-audio-s-d.lib;opengl32.lib;freetype.lib;winmm.lib;gdi32.lib;openal32.lib;flac.lib;vorbisenc.lib;vorbisfile.lib;vorbis.lib;ogg.lib;
for debug
Title: Re: Unresolved external symbol error
Post by: fallahn on January 02, 2021, 12:09:50 pm
Did you define SFML_STATIC ?
Title: Re: Unresolved external symbol error
Post by: Trigonaut on January 03, 2021, 10:32:16 pm
Did you define SFML_STATIC ?

yes
Title: Re: Unresolved external symbol error
Post by: eXpl0it3r on January 03, 2021, 11:24:29 pm
The linker issue is related to your own code.
Check that you're including the correct headers, have header guards and don't have cycling includes.
Title: Re: Unresolved external symbol error
Post by: kojack on January 06, 2021, 01:05:52 am
What it looks like here is you have a class something like:
class GameRenderer
{
public:
   static sf::RenderTexture render;
};
But static members of a class don't allocate memory (they aren't exactly the same as statics outside of a class). Somewhere in a cpp file you'll need to do:
sf::RenderTexture GameRenderer::render;
This will allocate the memory for the render variable, which is what the linker error was saying is missing.