SFML community forums

General => General discussions => Topic started by: TueJoshua on August 28, 2017, 01:04:01 pm

Title: Installing SFML on Mac (Sierra), XCode (Command line tools only)
Post by: TueJoshua on August 28, 2017, 01:04:01 pm
UPDATE: I've realized that I put this thread in the "non-help" section by mistake.

If there's a way to move the thread or there's something else that should be done, please let me know :)

=============================

I'm trying to install for use with XCode command line C++ tools.

I've followed the guide at https://www.sfml-dev.org/tutorials/2.4/start-osx.php
- Copied frameworks, not dylibs
- Not copied the (optional) templates

I haven't been able to use the "Create your first SFML program" as I only have command line tools (and not the "whole" Xcode) installed.
I've tried compiling the "Pong" example included in the SFML download as well as my own code, simply trying to open a sf::RenderWindow (copied the statement from one of the examples).
Whatever I do, I always get the same "Undefined symbols for architecture x86_64" error message.
This includes trying to follow https://stackoverflow.com/questions/14228856/how-to-compile-c-with-c11-support-in-mac-terminal, which I tried as a result of the comment "If you downloaded the "Clang" version from the download page, you should select C++11 with Clang and libc++."

Any tips?

Verbose output when trying to compile (the example) Pong.cpp - see attached.
Title: Re: Installing SFML on Mac (Sierra), XCode (Command line tools only)
Post by: Hiura on August 29, 2017, 07:14:41 pm
You need to link against SFML with the `-framework` option.
Title: Re: Installing SFML on Mac (Sierra), XCode (Command line tools only)
Post by: TueJoshua on September 01, 2017, 03:47:12 pm
Tried adding "-framework SFML" to the parameter list, I get the exact same result

(If I try "-framework SFM", I get an additional warning that the .framework file is not found, so it does connect to the framework file...)

Any further suggestions?
Title: Re: Installing SFML on Mac (Sierra), XCode (Command line tools only)
Post by: Hiura on September 01, 2017, 03:51:16 pm
Yes. The frameworks you need to link have the same name as the dylibs: -framework sfml-audio -framework sfml-system .... SFML.framework only contains header files.
Title: Re: Installing SFML on Mac (Sierra), XCode (Command line tools only)
Post by: TueJoshua on September 06, 2017, 10:24:47 am
Thanks, that worked!

(technically, the dylibs (which I haven't installed) have different names, e.g. "libsfml-audio.dylib" - it's the framework file names you want (which are in fact "sfml-audio" etc.)
Title: Re: Installing SFML on Mac (Sierra), XCode (Command line tools only)
Post by: Hiura on September 06, 2017, 11:06:35 am
I meant it's the same command except using -framework instead of -l. The linker resolves the lib prefix and .dylib postfix. Anyway, glad you got it working; have fun now!