Xcode, C ++ and SFML. Library problems

I am trying to compile simpel code that will show me a window using Xcode with my mac. Everything seems to work and I am getting "Build Succeeded". But then nothing happens and I get the message:

dyld: library not loaded: @ rpath / libsfml-audio.2.4.dylib

Retrieved from: / Users / zeeshanaslam / Library / Developer / Xcode / DerivedData / test-frpvsmylufuctqaphblszdoivflt / Build / Products / Debug / test

Reason: Image not found

I am very new to programming, so please help me with this problem.

My code:

#include <SFML/Graphics.hpp>

int main(){
    sf::RenderWindow window(sf::VideoMode(640,480),"TEST");

    while (window.isOpen()){
        sf::Event evnt;

        while (window.pollEvent(evnt)){
            if(evnt.type == evnt.Closed)
                window.close();
        }

        window.clear();
        window.display();
    }
}

      

I'm not sure if the code or Xcode is causing this.

+3


source to share


1 answer


I was able to run this code completely (OS X 10.11.6, Xcode 8.2.1). Here are my steps to get it running:



  • brew install sfml

    in the terminal.
  • Added /usr/local/sfml/cellar/sfml/2.4.2/include

    to my header search path in xcode.
  • In /usr/local/sfml/cellar/sfml/2.4.2/lib

    I dragged and dropped audio graphics, network, system and windowed dylibs into xcode. This is enough for xcode to link (and run) your code.
+1


source







All Articles