2011-12-17 9 views
5

Esto puede parecer una pregunta bastante 'novata': he descargado SFML-1.6 para Mac y he colocado los marcos en mi carpeta/Library/Frameworks. Después de tratar de compilar una aplicación SFML de ejemplo, recibo errores de enlazador en casi todas las llamadas que hago a SFML. No estoy seguro de lo que me estoy perdiendo? No tengo mucha experiencia con OSX y Frameworks, así que tal vez deba vincularme a las bibliotecas por algún otro método.Errores del enlazador en OS X

de salida, si ayuda:

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) 

Respuesta

2

Parece que su problema también podría ser contestada de un desarrollador con experiencia en OS X, pero ya que es una pregunta relacionada SFML demasiado, me recomendamos que se ponga en contacto con el desarrollador (o al menos lo portó todo) de SFML para OS X: hirua. (¿O está aquí también en Stackoverflow?)

Además, existe un instruction para compilar (y utilizar) la biblioteca SFML 2.0 en el foro. Quizás también ayude para su versión 1.6.

(me gustaría añadir esto sólo un comentario, pero parece que mi reputación no es tan grande (aún))

6

Usted tendrá que añadir dos banderas a las opciones de vinculador:

-framework SFML 

Esto le dice al enlazador a utilizar en el marco /Library/Frameworks/SFML.framework

Además, usted tiene que incluir -lsfml-whatever para cada biblioteca que está utilizando:

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

Por lo tanto, una línea completa enlazador podría ser:

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

Esto no es inmediatamente obvia desde el Mac OS X SFML construir documentos, pero sí es necesario tanto.

+0

No, '-framework SFML' es inútil. Es un marco ficticio que contiene solo encabezados. Si instaló dylibs, probablemente también instaló los encabezados en '/ usr/local /', por lo que no necesita este marco adicional. – Hiura