Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Unresolved external symbol error  (Read 1710 times)

0 Members and 1 Guest are viewing this topic.

Trigonaut

  • Newbie
  • *
  • Posts: 2
    • View Profile
Unresolved external symbol error
« 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

fallahn

  • Sr. Member
  • ****
  • Posts: 492
  • Buns.
    • View Profile
    • Trederia
Re: Unresolved external symbol error
« Reply #1 on: January 02, 2021, 12:09:50 pm »
Did you define SFML_STATIC ?

Trigonaut

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Unresolved external symbol error
« Reply #2 on: January 03, 2021, 10:32:16 pm »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10819
    • View Profile
    • development blog
    • Email
Re: Unresolved external symbol error
« Reply #3 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.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

kojack

  • Sr. Member
  • ****
  • Posts: 314
  • C++/C# game dev teacher.
    • View Profile
Re: Unresolved external symbol error
« Reply #4 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.