Linker Errors on OS X

This may seem like a pretty noob question: I downloaded SFML-1.6 for Mac and I put the frameworks in my / Library / Frameworks folder. After trying to compile an example SFML application, I get linker errors in almost every call I make for SFML. I'm not sure what I am missing? I don't have much experience with OSX and Frameworks, so maybe I need to link to libraries in some other way?

Conclusion if this 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)
+5
source share
2 answers

You need to add two flags to the linker options:

-framework SFML

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

, -lsfml-whatever , :

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

, :

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

SFX Mac OSX, .

+6

, OS X, , SFML, (, , ) SFML OS X: hirua. ( Stackoverflow?)

, ( ) SFML 2.0 . , 1.6.

( , , , ())

+2

All Articles