简体   繁体   中英

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM