Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode, C++ and SFML. Library issues

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

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

Referenced 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 could any one help me with this problem.

My code is:

#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 am not sure if its the code or Xcode is what causing the problem.

like image 902
CoachZA Avatar asked Dec 14 '25 15:12

CoachZA


1 Answers

I managed to run this code completely fine (OS X 10.11.6, Xcode 8.2.1). Here were my steps to getting it to run:

  1. brew install sfml in the terminal.
  2. Added /usr/local/sfml/cellar/sfml/2.4.2/include to my header search path in xcode.
  3. In /usr/local/sfml/cellar/sfml/2.4.2/lib, I dragged the audio, graphics, network, system and window dylibs into xcode. This is sufficient for xcode to link (and run) your code.
like image 78
Owen Morgan Avatar answered Dec 16 '25 09:12

Owen Morgan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!