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

Author Topic: Resolved: Linker Error, unresolved external  (Read 1535 times)

0 Members and 2 Guests are viewing this topic.

danielsega

  • Newbie
  • *
  • Posts: 6
    • View Profile
Resolved: Linker Error, unresolved external
« on: February 11, 2014, 10:30:24 pm »
I just started looking into SFML and i decide to break down that simple program into a Game class, but i am getting this errors:

Quote

Error   1   error LNK2001: unresolved external symbol ...
Error   2   error LNK1120: 1 unresolved externals

Here is my game class, i also include SFML/graohics.hpp so i could initialize a renderwindow the the circle shape from the example:

Quote
#include<SFML\Graphics.hpp>

class Game
{
public:
   Game();
   ~Game();
   void Run();
private:
   //--Behaviour
   void Update();
   void Render();

   //--Data Members
   sf::RenderWindow mWindow;   
   sf::CircleShape mPlayer;
};

In my main all i have a game object and use the Run function, but i get that linker error. However  it works fine in the main class.
« Last Edit: February 11, 2014, 11:29:13 pm by danielsega »

SLC

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: Linker Error, unresolved external
« Reply #1 on: February 11, 2014, 10:42:08 pm »
I don't work with Microsoft Visual C++ and you seem to be using it. You should follow this tutorial and see if you linked your project to the SFML's libraries (the .lib files) and if SFML is compiled as static then you should also link your project to SFML's dependencies. Read more here, even if it's for MinGW its still applies to MSVC except the libraries are .lib files.

danielsega

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Linker Error, unresolved external
« Reply #2 on: February 11, 2014, 10:57:18 pm »
I don't work with Microsoft Visual C++ and you seem to be using it. You should follow this tutorial and see if you linked your project to the SFML's libraries (the .lib files) and if SFML is compiled as static then you should also link your project to SFML's dependencies. Read more here, even if it's for MinGW its still applies to MSVC except the libraries are .lib files.

Like i said before i work perfectly well with the code in main, when i break it down into classes it gives the error. I'll try to use the dynamic library to see if it works.

Edit: I fixed it, i removed the destructor from my Game class and it works fine now.

« Last Edit: February 11, 2014, 11:28:47 pm by danielsega »