SFML community forums

Help => General => Topic started by: GroundZero on October 19, 2011, 04:09:36 pm

Title: Installing on Mac (Xcode)
Post by: GroundZero on October 19, 2011, 04:09:36 pm
Dear reader,

could someone please provide me (and a lot of other people lol) with a step by step tutorial on how to get SFML working on a mac with xcode. Been trying for 2 months now without success.

It would be much appreciated if you could do it step by step i.e. how to use cmake to unpack everything, then copy the files to the right folders, then what and how to add the links to the .h files in C++ and so on.

You'll be my hero for a life time if someone can do this ;)
Title: Installing on Mac (Xcode)
Post by: Hiura on October 19, 2011, 08:29:10 pm
currently there is no such tutorial. but you can get all the required information from this post : http://www.sfml-dev.org/forum/viewtopic.php?p=23608#23608 if you want to use SFML 2.0 (still under development) or refer to http://www.sfml-dev.org/tutorials/1.6/ for SFML 1.6.

however, it's highly recommended to be used to Xcode and C++ programming (Object Oriented Programming and how libraries roughly work) before using SFML on mac.
Title: Installing on Mac (Xcode)
Post by: GroundZero on October 19, 2011, 10:10:18 pm
Thanks for your answer and the links :)

I know how to program in C++ (almost advanced) just cant seem to get SFML working on my Mac. On my PC its working fine, but I want it on my mac ;)
Title: Installing on Mac (Xcode)
Post by: sbroadfoot90 on October 20, 2011, 03:10:16 am
Hey man, I'm using Xcode4 and I managed to get it working in under 20 minutes with the tutorial here (http://www.sfml-dev.org/tutorials/2.0/compile-with-cmake.php) and modifying it a bit for mac.

Are you using Xcode 3 or 4? I'll be happy to help if it's 4 :)[/url]
Title: Installing on Mac (Xcode)
Post by: GroundZero on October 20, 2011, 02:20:55 pm
Dear sbroadfoot90,

I am using the newest version of xCode (which is 4 right?) on my Mac which is running OS X Lion.

It would be awesome if you could assist me a little bit. I will first try to follow the tutorial you provided in the link.

Thank you for your reply!
Title: Installing on Mac (Xcode)
Post by: sbroadfoot90 on October 21, 2011, 12:30:10 am
OK, basically what I did,

1) Clone the git repository.

You can do this two ways:

a) by clicking here (https://github.com/SFML/SFML) and then clicking on Clone in Mac. You will need to download the github app.

Screenshot (http://grab.by/b6as)

Choose to save it in ~/SFML (or any other folder).

b) Alternatively, if you have git installed in your bash terminal, simply type

$ cd ~
$ git clone https://github.com/SFML/SFML.git

2) Download and install C-make. Open it.

- Building release
Where it says "Where is the source code?", type ~/SFML
Where it says "Where to build the binaries", type ~/SFML/build-release
Then click configure, choose Unix makefile and default compiler and OK.... then wait a bit.

There will be a bunch of options in red. Tick all of them (if you don't have doxygen then leave BUILD_DOC unticked), and make sure CMAKE_BUILD_TYPE is Release.

Click configure again, and then click generate.

- Building debug
Do everything the same, but build in  ~/SFML/build-debug, and change CMAKE_BUILD_TYPE to Debug.

3) Compiling and installing

Open up a terminal and type

$ cd ~/SFML/build-release
$ make clean
$ sudo make install

Enter your password

then type

$ cd ../debug
$ make clean
$ sudo make install

Everything should be installed properly now.

4) Making a project with Xcode4!

Open up Xcode4, then click File > New > New Project. The screen should now look like this (http://grab.by/b6ak). Choose either one, and there you go!

If the templates didn't come up, then you probably forgot to tick INSTALL_XCODE4_TEMPLATES in cmake, OR, you didn't click configure the second time.

Any problems with this, just ask :)


EDIT: Made the instructions a bit clearer based on some replies
Title: Installing on Mac (Xcode)
Post by: GroundZero on October 21, 2011, 11:16:11 am
awesome thank you so much! I am going to try this out in 2 hours :D
Title: Installing on Mac (Xcode)
Post by: Aranri on October 29, 2011, 10:43:32 am
Good Day

I tried to follow all of your instructions (only put the folder inside my home folder -> myname/SFML-source/SFML-make/release

and all seemed to work well, except when i typed sudo make install inside the terminal:

make: *** No rule to make target `install'.  Stop.

What did I do wrong? I have the following files inside the release folder:

(https://lh4.googleusercontent.com/-bkHU7zz89_Y/Tqu8F2ELgOI/AAAAAAAAALg/5MfogeiqDds/s637/Screen%2BShot%2B2011-10-29%2Bat%2B10.38.38.png)

If you could help me out I really would appreciate it   :)
Title: Installing on Mac (Xcode)
Post by: Bitbridge on October 29, 2011, 01:28:48 pm
It looks like you used Cmake to create a Xcode-project. You can open that .xcodeproj using Xcode and then run the "install"-target, which will compile and copy the SFML libraries/header files into /usr/local. You probably have to run Xcode using sudo.

If you want to create a makefile, you have to choose "Unix makefile" when configuring Cmake.

Also, since I've already written in this topic: How can I deploy my SFML application via Xcode (using the SFML Xcode 4 Template)? I can build it for archiving, which will build the release .app, however, it doesn't copy the SFML libraries. Do I have to manually add them (Build phases)?
Title: Installing on Mac (Xcode)
Post by: Aranri on October 29, 2011, 03:00:34 pm
Thank you for your reply Codevine.
I was actually refering to the post of sbroadfoot90 and the third step:
Quote
3) Compiling and installing

Open up a terminal and type

$ cd ~/SFML-make/release
$ sudo make install

Enter your password

then type

$ cd ../debug
$ sudo make install

Everything should be installed properly now.


and that sudo make install here does not work for me.The libraries etc. are still missing (I also have no templates)

Because if I try to build the install target (and i opened Xcode with sudo open Xcode.app) I have 105 issues.

They sound like the following:
in allocator.h:
In file included from /Users/myName/SFML-source/SFML/src/SFML/System/Err.cpp
in cstddef
/Developer/SDKs/MacOSX10.6.sdk/usr/include/c++/4.2.1/cstddef:53: error: expected constructor, destructor, or type conversion before '(' token
'_GLIBCXX_END_NAMESPACE' does not name a type
Bits/time_members.h: No such file or directory

etc...
So i think something is still missing, but I really don't know what it is.
Title: Installing on Mac (Xcode)
Post by: Bitbridge on October 29, 2011, 03:17:34 pm
When clicking on Configure in CMake the first time it asks for the generator. What did you choose there? If you want to use 'sudo make install', you will have to choose "Unix makefile". However, on your screenshot it looks like you chose the Xcode generator, which is why it created a Xcode project (so there is no rule to make target 'install').

Anyways, it also should work using Xcode (it does for me, using 10.7), so I'm not sure about the error(s). If you have the same error(s) using the unix makefile, you probably have to wait for Hiura.
Title: Installing on Mac (Xcode)
Post by: Aranri on October 29, 2011, 07:52:41 pm
Thank you so much, that was exactly the problem!

Now it could install it perfectly on my Laptop, unfortunatley it didn't work on my iMac.
After I typed sudo make install I many errors similar to those:

Quote

[  8%] Building CXX object src/SFML/System/CMakeFiles/sfml-system.dir/Err.cpp.o

/Developer/SDKs/MacOSX10.6.sdk/usr/include/c++/4.2.1/iosfwd:44:28: error: bits/c++config.h: No such file or directory
/Developer/SDKs/MacOSX10.6.sdk/usr/include/c++/4.2.1/iosfwd:45:29: error: bits/c++locale.h: No such file or directory
/Developer/SDKs/MacOSX10.6.sdk/usr/include/c++/4.2.1/iosfwd:46:25: error: bits/c++io.h: No such file or directory

or
Quote

/Developer/SDKs/MacOSX10.6.sdk/usr/include/c++/4.2.1/bits/allocator.h:53:31: error: bits/c++allocator.h: No such file or directory
In file included from /Developer/SDKs/MacOSX10.6.sdk/usr/include/c++/4.2.1/bits/basic_ios.h:44,
                 from /Developer/SDKs/MacOSX10.6.sdk/usr/include/c++/4.2.1/ios:50,
                 from /Developer/SDKs/MacOSX10.6.sdk/usr/include/c++/4.2.1/ostream:45,
                 from /Users/rogerkueng/SFML-source/SFML/include/SFML/System/Err.hpp:32,
                 from /Users/rogerkueng/SFML-source/SFML/src/SFML/System/Err.cpp:28:


In theory i did everything the same way on both machines, but somehow on one it doesn't want to work.

Am I missing some other library or did I not install something?

Thank you again so much for your help!
Title: Installing on Mac (Xcode)
Post by: Ceylo on October 30, 2011, 10:28:23 am
Looks like Xcode & co aren't correctly installed, since you're missing some standard headers.
Title: Installing on Mac (Xcode)
Post by: Aranri on October 30, 2011, 12:05:59 pm
Thank you Ceylo!

It was exactly that, I reinstalled Xcode and afterward everything worked!

Now I can finally start coding :D
Title: Installing on Mac (Xcode)
Post by: thecruuk on November 05, 2011, 07:44:17 pm
i followed the tutorial but i´m getting this error:
(http://i.imgur.com/GD48T.png) (http://imgur.com/GD48T)
can someone help me?
Title: Installing on Mac (Xcode)
Post by: Hiura on November 06, 2011, 03:51:28 pm
The "Where is the source code" field is wrong : remove /src/SFML and it should work.
Title: Installing on Mac (Xcode)
Post by: thecruuk on November 06, 2011, 07:56:31 pm
thank you so much : D
Title: Installing on Mac (Xcode)
Post by: himatako on November 20, 2011, 12:15:00 pm
I tried to run from XCode4.2, but it gave me this error

Code: [Select]

Command /bin/sh failed with exit code 2


Can somebody please help me fix this? Thank you!


EDITED :

After proceeding to use makefile instead, I think I successfully created shared libraries. However, for some reasons, the XCode4 template is never installed and I have to install manually. I checked the flag already, and I have done this three or four times so I'm sure I didn't miss the flag.

Now that I create XCode4 SFML project, I can't compile it. The error it gave me is

Code: [Select]

ld: framework not found sfml-system
Command /Developer/usr/bin/clang++ failed with exit code 1


However, I have included all the libsfml-xxx.dylib already. What seems to be the problem here?
Title: Installing on Mac (Xcode)
Post by: Hiura on November 20, 2011, 07:22:20 pm
Q & A : https://github.com/SFML/SFML/blob/master/xcode/templates/readme.txt

Quote
However, for some reasons, the XCode4 template is never installed and I have to install manually. I checked the flag already
Did you click on "Configure" after checking the checkbox ?
Title: Installing on Mac (Xcode)
Post by: himatako on November 21, 2011, 04:08:53 am
Quote from: "Hiura"
Q & A : https://github.com/SFML/SFML/blob/master/xcode/templates/readme.txt

Quote
However, for some reasons, the XCode4 template is never installed and I have to install manually. I checked the flag already
Did you click on "Configure" after checking the checkbox ?


Thanks for the readme link! I'll follow it and see what happens.

As for the template, yes, I made sure that all the items in the configure menu were white before I click generate.
Title: Installing on Mac (Xcode)
Post by: Hiura on November 21, 2011, 10:53:53 am
You need to validate your changes by clicking "configure" before generating the Makefile (see CMake tutorial on the main web site).
Title: Installing on Mac (Xcode)
Post by: Phalanx on November 22, 2011, 08:23:30 am
First post. Hello, and thanks so much for all of the work on SFML!

In response to the original thread question -- I'm completely new to this, and have decided to document my experience. Installing SFML 2 on Xcode 4 took me about 4 hours (mainly due to me skipping steps or not reading correctly). Here is a basic walkthrough that groups together all of the help resources on this site:

http://gameandcode.com/post/13145870775/sfml-2-0-with-xcode-4
Title: Installing on Mac (Xcode)
Post by: sbroadfoot90 on November 22, 2011, 10:30:47 pm
Thanks for your lovely post phalanx! Your explanation is quite good and nicely laid out :)
Title: Installing on Mac (Xcode)
Post by: DigiByte on November 27, 2011, 01:44:10 pm
the link in your tutorial you gave (abroad) is dead...And now i can't find the git repository. https://github.com/SFML/SFML i think this is the same, but there isn't a button like in your first screenshot "clone to mac". So i don't know where i have to get it.

Please help me! :) [/url]
Title: Installing on Mac (Xcode)
Post by: sbroadfoot90 on November 30, 2011, 11:41:52 am
I just checked all the links in my post. They all work.

If you are talking about this bit here, which turns out to have become a link without me adding url tags,

Quote from: "sbroadfoot90"

$ cd ~
$ git clone https://github.com/SFML/SFML.git


this is not meant to be clicked on, this is something you type into your terminal to clone the git repository.

The clone in mac button should come up if you are using a mac, if it doesn't come up, just clone using the command line using the two commands I just quoted.
Title: Installing on Mac (Xcode)
Post by: Dominater on December 08, 2011, 12:47:20 am
Hey Everyone,

I'm trying to get it to work on Xcode 4 on Lion OS

However the Templates are not being installed correctly, I tried both manually and using cmake as in here.

I checked the Templates checkbox for sure(did it twice),

I:
typed in the paths
clicked configure
checked all the checkboxes
clicked configure
clicked generate


After I clicked the configure for the second time, all the checkboxes unchecked itself, is this what's suppose to happen?


Thanks
Title: Installing on Mac (Xcode)
Post by: Hiura on December 08, 2011, 10:19:52 am
Quote from: "Dominater"
However the Templates are not being installed correctly, I tried both manually and using cmake as in here.
What do you mean exactly ? When you install them manually they don't appear in Xcode ?  They don't work as expected ? .... ?
Title: Installing on Mac (Xcode)
Post by: dotty on January 12, 2012, 10:51:22 pm
Hello, I followed this on OS X 10.6.8 and it installed fine! However, I don't seem to have the XCODE templates for XCODE (Version 3.2.6 (1761)).

I still have the old templates for 1.6. So when I load up a new project, and I hit "run" I get errors.
Title: Installing on Mac (Xcode)
Post by: Hiura on January 13, 2012, 09:34:52 am
https://github.com/SFML/SFML/blob/master/tools/xcode/templates/readme.txt

http://www.sfml-dev.org/forum/viewtopic.php?p=23677#23677