I am trying to start a basic C++ project with link to SFML library. I have unzipped the SFML library to folder /Users/mulperi/cpplib/sfml and I have added that to Include Search Path and Library Search Path.
My code is simple, I followed a tutorial on Youtube (also tried different ready-made codes):
#include <iostream>
#include <SFML/Graphics.hpp>
int main() {
sf::RenderWindow window(sf::VideoMode(640, 480), "First SML Window");
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
switch (event.type) {
case sf::Event::Closed:
window.close();
break;
default:
break;
}
}
window.clear();
window.display();
}
return 0;
}
The build succeeds so the paths should be fine. I don't get the window, instead I have these outputs:
Thread 1:
dyld`__abort_with_payload:
0x10003b1e0 <+0>: movl $0x2000209, %eax ; imm = 0x2000209
0x10003b1e5 <+5>: movq %rcx, %r10
0x10003b1e8 <+8>: syscall
-> 0x10003b1ea <+10>: jae 0x10003b1f4 ; <+20>
0x10003b1ec <+12>: movq %rax, %rdi
0x10003b1ef <+15>: jmp 0x10003aa48 ; cerror_nocancel
0x10003b1f4 <+20>: retq
0x10003b1f5 <+21>: nop
0x10003b1f6 <+22>: nop
0x10003b1f7 <+23>: nop
Output:
dyld: Library not loaded: @rpath/libsfml-system.2.5.dylib
Referenced from: /Users/mulperi/Library/Developer/Xcode/DerivedData/sfml_1-cgodahbmxiufqnhhglbsyfuzvdvz/Build/Products/Debug/sfml_1
Reason: image not found
(lldb)
I am using Xcode 9.3.1 on High Sierra 10.13.4
Update: I also tried moving the SFML folder inside the project folder and even tried splitting up include,libs,frameworks,extlibs tu /usr/local like in the SFML tutorial but I always get the same output.
Ok I got it working after reading the getting started tutorial carefully again. On Mac, they recommend using the Framework files, so what I did was:
Note: No need to add Include Search Paths or Library Search Paths with this method.