6

This may seem like quite a 'noob' question: I've downloaded SFML-1.6 for Mac and I have placed the frameworks into my /Library/Frameworks folder. After trying to compile an example SFML application I get linker errors for pretty much every call I make to SFML. I'm not sure what I am missing? I've not got much experience with OSX and Frameworks so perhaps I need to link to the libraries by some other method?

Output, if it helps:

Undefined symbols for architecture x86_64:
  "sf::VideoMode::VideoMode(unsigned int, unsigned int, unsigned int)", referenced from:
      osx_init::init() in osx_init.o
  "sf::RenderWindow::RenderWindow(sf::VideoMode, std::string const&, unsigned long, sf::WindowSettings const&)", referenced from:
      osx_init::init() in osx_init.o
  "sf::RenderTarget::PreserveOpenGLStates(bool)", referenced from:
      osx_init::init() in osx_init.o
  "sf::Image::Image()", referenced from:
      osx_init::init() in osx_init.o
  "sf::Image::LoadFromFile(std::string const&)", referenced from:
      osx_init::init() in osx_init.o
  "sf::Color::Color(unsigned char, unsigned char, unsigned char, unsigned char)", referenced from:
      osx_init::init() in osx_init.o
  "sf::Sprite::Sprite(sf::Image const&, sf::Vector2<float> const&, sf::Vector2<float> const&, float, sf::Color const&)", referenced from:
      osx_init::init() in osx_init.o
  "sf::Image::GetWidth() const", referenced from:
      osx_init::init() in osx_init.o
  "sf::Image::GetHeight() const", referenced from:
      osx_init::init() in osx_init.o
  "sf::Image::GetPixelsPtr() const", referenced from:
      osx_init::init() in osx_init.o
  "sf::Image::~Image()", referenced from:
      osx_init::init() in osx_init.o
  "sf::Clock::Clock()", referenced from:
      osx_init::init() in osx_init.o
  "sf::Window::IsOpened() const", referenced from:
      osx_init::init() in osx_init.o
  "sf::Window::GetEvent(sf::Event&)", referenced from:
      osx_init::init() in osx_init.o
  "sf::Window::Close()", referenced from:
      osx_init::init() in osx_init.o
  "sf::Clock::GetElapsedTime() const", referenced from:
      osx_init::init() in osx_init.o
  "sf::Unicode::Text::Text(char const*)", referenced from:
      osx_init::init() in osx_init.o
  "sf::Font::GetDefaultFont()", referenced from:
      osx_init::init() in osx_init.o
  "sf::String::String(sf::Unicode::Text const&, sf::Font const&, float)", referenced from:
      osx_init::init() in osx_init.o
  "sf::Drawable::SetPosition(float, float)", referenced from:
      osx_init::init() in osx_init.o
  "sf::Drawable::SetColor(sf::Color const&)", referenced from:
      osx_init::init() in osx_init.o
  "sf::Window::Display()", referenced from:
      osx_init::init() in osx_init.o
  "sf::RenderWindow::~RenderWindow()", referenced from:
      osx_init::init() in osx_init.o
  "vtable for sf::Sprite", referenced from:
      sf::Sprite::~Sprite() in osx_init.o
  "sf::Drawable::~Drawable()", referenced from:
      sf::Sprite::~Sprite() in osx_init.o
      sf::String::~String() in osx_init.o
  "vtable for sf::String", referenced from:
      sf::String::~String() in osx_init.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
jww
  • 97,681
  • 90
  • 411
  • 885
chrisburke.io
  • 1,497
  • 2
  • 17
  • 26

2 Answers2

6

You'll need to add two flags to the Linker options:

-framework SFML

This tells the linker to use the framework in /Library/Frameworks/SFML.framework

In addition, you have to include -lsfml-whatever for each library you're using:

-lsfml-system
-lsfml-window
-lsfml-graphics
-lsfml-audio
-lsfml-network

So, a complete linker line might look like:

g++ -framework SFML -lsfml-graphics -lsfml-audio -lsfml-window -lsfml-system

This is not immediately obvious from the Mac OSX SFML build docs, but you do need both.

nateware
  • 197
  • 1
  • 4
  • No, `-framework SFML` is useless. It's a dummy framework that contains only headers. If you installed dylibs you probably also installed headers in `/usr/local/` so you don't need this extra framework. – Hiura May 28 '14 at 17:22
2

It seems your problem could also be answered from a experienced developer on OS X but since it's a SFML related question too, I'd advice you to get in contact with the developer (or at least he ported the whole thing) of SFML for OS X: hirua. (Or is he here on Stackoverflow too?)

Additionally there is a instruction for building (and using) the SFML 2.0 library in the forum. Maybe it helps too for your 1.6 version.

(I'd like to add this just a comment but it seems my reputation isn't that great (yet))

Lukas
  • 2,461
  • 2
  • 19
  • 32