On This Page
A. Introduction
If you are using the Mac OS, you will need to do the following two steps to install Codeblocks and Xcode: Install Xcode Command Line for your version of Mac OS X (10.7 is Lion, 10.8 is Mountain Lion). You can obtain Xcode Command. Follow the instructions for installation. Step 2: Install CodeBlocks. Visit the CodeBlocks downloads page. Scroll to the bottom of the page until you find the download for the Mac; Click on the link (sourceforge recommended!) Once it finishes downloading, click on the file and follow any instructions for installation.
This document describes how to install SFML on XCode for the course CS-11: Introduction to Programming Concepts and Methodology, C++. For Windows computers, see How to Install SFML in Code::Blocks for Windows. For Linux computers, see How to Install Code::Blocks and SFML for Linux.
SFML is a free and open source library that provides a simple object-oriented interface to graphics, sound and other parts of a personal computer. It has five main modules: system, window, graphics, audio and network.
B. Installing XCode
SFML does not require the latest version of XCode. Any version starting with Lion (10.7) or later is acceptable and there is no need to update to the latest version of XCode.
Installing XCode
If you do not have XCode or want to update, use the following instructions:
- Register as an Apple developer at https://developer.apple.com/programs/register/.
Registering as an Apple developer is free for individuals. The Apple website may imply that you must pay, but the link should take you directly to the free signup page.
- Go to Apple Developer and login.
After login, you can download the latest version of XCode in the Mac App Store as well as older versions.
- Once downloaded, install XCode from the disc image (dmg) file. Drag and drop the file into your computer's Application folder.
- After installing XCode, download and install the command-line tools as well.
Command-line tools can be downloaded from the Apple Developer. Some versions of XCode allow you to install the command-line tools from: XCode > Preferences > Downloads > Command Line Tools.
To learn how to use XCode, look up tutorials on the Apple Developer site or with a search engine.
More Information
- Apple XCode for C and C++: from Cprogramming.com
- Building from the Command Line with XCode FAQ: from the Apple Developer documentation
C. Installing SFML
- Go to the SFML download page and follow the link to the latest stable version.
- Download the SFML libraries for your version of XCode and place them in a suitable location.
Use Clang for OS X 10.7 (Lion 2012) or later. Earlier versions of OS X do not have pre-built downloads.
- Open the Terminal application.
The Terminal application is located in the Utilities subfolder of the Applications folder.
- In the Terminal window,
cd
to the download location.For example:
cd Downloads
- Run the install script by typing:
./install.sh
followed by the Enter key.The script will prompt you for your password and install the components correctly.
Codeblocks Install Linux
More Information
Install Codeblocks On Mac
- SFML and XCode (Mac OS X): from the SFML tutorials
D. Creating an SFML Project
In this section we create a test project to verify the SFML installation. We can use these instructions as a starting point for other new projects as well.
Download And Install Codeblocks
- Start XCode and select
File > New Project...
then chooseSFML
in the left column and double-click onSFML App
. - In the next window, fill in the required fields and then press the Next button.
- If you downloaded the 'GCC' version, select C++98 with GCC and libstdc++ and target 10.5.
- If you downloaded the 'Clang' version, select C++11 with Clang and libc++.
- In the main.cpp file, copy and paste the following program code.
- Run the project and verify you see the following graphics window.
More Information
- Create your first SFML program: from the SFML tutorials