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

Author Topic: Unresolved Externals when using Font  (Read 1340 times)

0 Members and 1 Guest are viewing this topic.

kopimi

  • Newbie
  • *
  • Posts: 2
    • View Profile
Unresolved Externals when using Font
« on: December 27, 2010, 03:30:18 am »
I've been messing about with the SFML 1.6 libraries lately and very much enjoying the process. I started on the Displaying Text tutorial and was let down when, after following all the rules and guidelines set by the tutorials, I got linker errors:

Code: [Select]
1>main.obj : error LNK2001: unresolved external symbol "private: static unsigned int * sf::Font::ourDefaultCharset" (?ourDefaultCharset@Font@sf@@0PAIA)

The full source code to my project is as follows:

Code: [Select]
#include <SFML/Graphics.hpp> //Contains Graphics and Window stuff!

//We need to define SFML_DYNAMIC in order to use the dynamic libraries
#define SFML_DYNAMIC


int main()
{
//Creates a window, pretty simple
sf::RenderWindow app(sf::VideoMode(800, 600, 32), "SFML Window");

//Open a sprite
sf::Image image;
image.LoadFromFile("media/sprite/sprite.jpg");

sf::Sprite sprite;
sprite.SetImage(image);
sprite.SetColor(sf::Color(0, 255, 255, 128));
sprite.SetX(100.f);
sprite.SetY(200.f);
sprite.SetPosition(200.f, 100.f);
sprite.SetRotation(30.f);
sprite.SetCenter(0, 0);
sprite.SetScaleX(0.75f);
sprite.SetScaleY(0.75f);
sprite.SetBlendMode(sf::Blend::Multiply);
sprite.Move(10.f, 5.f);
sprite.Rotate(15);
sprite.Scale(1.5f, 1.5f);

//Create a view
sf::View view(sf::FloatRect(0, 0, 800, 600));
view.Zoom(2.f);
app.SetView(view);

//Create a font
sf::Font font;
font.LoadFromFile("media/font/Arial.ttf", 50);

//Create text
sf::String text("Beard Hole!", font, 50);
text.SetPosition(10.f, 500.f);

//The main loop checks if the window is still open!
while (app.IsOpened())
{
sf::Event msg; //Define an event
while (app.GetEvent(msg))
{
if (msg.Type == sf::Event::Closed)
app.Close();
}

app.Clear(sf::Color(0, 100, 200));
app.Draw(sprite);
app.Draw(text);
app.Display();
}

return EXIT_SUCCESS;
}


As you can see, I've defined SFML_DYNAMIC, I'm using the dynamic libraries and they're in the directory of my debug executable (The debug versions of course :v), I've linked the libraries etc.. Everything is all set and yet I'm still unable to use text, which is quite a big deal for me right now :(

Does anyone have a solution? Oh and I'm compiling in VS2008, no problems other than this.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Unresolved Externals when using Font
« Reply #1 on: December 27, 2010, 08:02:55 am »
Quote
As you can see, I've defined SFML_DYNAMIC

This is not the right way to do it. Look at the tutorial, there are even screenshots.
Laurent Gomila - SFML developer

kopimi

  • Newbie
  • *
  • Posts: 2
    • View Profile
Unresolved Externals when using Font
« Reply #2 on: December 28, 2010, 04:32:59 am »
Quote from: "Laurent"
Quote
As you can see, I've defined SFML_DYNAMIC

This is not the right way to do it. Look at the tutorial, there are even screenshots.


I'm so sorry, not 30 minutes after posting here I realized my mistake and it was all corrected. Thanks for responding with an answer anyway, though.

I love the library :)