Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Tutorial :: Installing SFML with CodeLite IDE  (Read 21820 times)

0 Members and 2 Guests are viewing this topic.

Hydra

  • Newbie
  • *
  • Posts: 37
    • View Profile
Tutorial :: Installing SFML with CodeLite IDE
« on: August 18, 2015, 06:22:34 pm »
Introduction
To start off let's recap on what SFML and CodeLite are. SFML is a graphics library for C++ that is designed to be simple. SFML stands for Simple and Fast Multimedia Library. CodeLite is a IDE. IDE stands for intergrated development environment. In simple terms an IDE is a editor for code that has special tools to help you develop faster. CodeLite is open-source, cross-platform. First of all I'll go over installing CodeLite, CodeLite is only supported on these operating systems so make sure one of them is yours:

Windows 7
Windows 8
Windows 8.1
Windows 10
Debian / Ubuntu
Fedora / OpenSUSE
ArchLinux
Mac OSX 10.8 and later
FreeBSD (this has no installer)


This tutorial is designed for SFML 2.3.1 and CodeLite 8.1.


Installing CodeLite 8.1
Lets start installing CodeLite 8.1. Go to http://downloads.codelite.org Select a package depending on what OS your on and whether your 64bit or 32bit. I'm Windows 64bit. We will be selecting a "CodeLite Stable Release". So I'll be clicking on CodeLite 8.2.0 for Windows 64 bit Installer Direct Link | SourceForge. Click Direct Link. It should start downloading and once it has downloaded run the .exe. From there it's just the basics of installing programs.


Downloading SFML 2.3.1
Okay, now lets download SFML now that we have CodeLite. Head over to http://www.sfml-dev.org/download/sfml/2.3.1/. You can see there's tabs with: Windows, Linux, Mac and All. The "All" tab contains the source code. We will be downloading the pre-made SFML folder though. Select a tab depending on your OS. Then select a version depending on whether your 32 bit or 64 bit. I'm on Windows 64 bit. If your on WIndows your going to want to download "GCC 4.8.1 TDM (SJLJ)". Ignore the 4.7.1 version. Click on "Download". Once SFML 2.3.1 has download you will get a .zip folder. Open it up and you should see a folder in it called SFML 2.3.1. Drag that folder to your C: drive. You should end up with SFML 2.3.1 in the C: drive next to folders with names like Program Files and Users. If this is true then you have correctly downloaded SFML 2.3.1.


Creating a project in CodeLite
Now you may be thinking you can just open CodeLite and start writing majestic code! Sadly that's not true. What your going to want to do is open up CodeLite 8.1. You should see a main view with tabs such as "New Workspace", "Open Workspace", Forums", Wiki". Click on "New Workspace". Select C++ and click OK. Now you can select the location and name. I set my location in my documents folder. So my "Workspace Path" is:

C:\Users\[username]\Documents

Now you want to select a workspace name. I set mine as "CodeLiteProjects". Enable "Create the workspace under a separate directory". Then click OK. Now you want to create a project to use SFML out. Click on "File" at the top left of the CodeLite window. Then click "New" and then "New Project". You will see a window pop up with a green box saying "New Project". Below that there will be the word Template then tabs called things like "GUI", "Console", "Others". Click on the plus sign next to "Console". It should expand out to reveal more things. Select "Simple Executable (g++)" and then click "Next >". Now you will see another window with the word "Project Name" and "Project Path". Don't edit Project Path, that is correct by default. For project name enter anything you want. I'll enter "SFML-Demo". Make sure "Create the project under a seperatre directory" is enabled. Then click "Next >".
There should be one last window with the word's "Compiler" and "Debugger". Presuming you have Mingw installed these will by default be correct. Just click "Finish".


Running SFML 2.3.1 in CodeLite
Okay, now we are on the last part! All we need to do is make sure CodeLite knows where SFML 2.3.1 is downloaded to. You should have a project in the "Workspace View" under "CodeLiteProjects". There will be a arrow to the left of the name of your project. Click that to expand the project. Do the same for a folder called "src". Now double click on "main.cpp".
By default main.cpp will have some random stuff in. On the top of the CodeLite window there will be a tab called "Build" click that then click "Run". It will ask you whether you want to build. Say yes and then it should run. It should open a console window with the output "hello world". Close that window. Now we know CodeLite is compiling correctly.
All we have to do now is tell CodeLite where to find SFML 2.3.1. In the workspace view you have your project name. Right click on it. At the bottom of the opened bit there will be Settings. Click on that. Now we see the project settings. There's a few tabs on the left. Click on "Compiler". In the center of the new window you will see text saying "Include Paths". Next to that is a text box. Remember when you downloaded and moved SFML 2.3.1. I download it to the C: drive. So enter in that text box "C:\SFML-2.3.1\include". That is just saying to CodeLite to go to a folder in SFML called include and look at the files in that. Below that text box is another called "Preprocessors". Write in that "SFML_STATIC". Now click on "Linker" on the tabs at the left of the window. You will see a text box called "Libraries Search Path". Enter "C:\SFML-2.3.1\lib". That tells CodeLite to open the files in the SFML folder in the the lib folder. Below that is a text box called libraries. Click the "..." to the right of it. A window will pop up. In that write this:

sfml-graphics
sfml-window
sfml-audio
sfml-network
sfml-system


Now your nearly done! Click "OK" and you should return to the main window. Edit the main.cpp file and enter:

#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(800, 600), "Majestic Window");
   
    while (window.isOpen())
    {
        sf::Event event;
       
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
            {
                window.close();
            }
        }
       
        window.display();
    }
}



Getting the DLLs
Now if you click "Build" and then "Run". You will be so happy! Then you get annoying popups with called System Error saying they can't find SFML files. How annoying! To fix this we need to add the SFML .dll files to the same directory as our project. Open up where you downloaded SFML (C:\SFML-2.3.1\bin) to and then navigate to the bin folder in that. Copy all the files in that. Then go to where your CodeLite project is (C:\Users\[username]\Documents\CodeLiteProjects\SFML-Demo). There should be a folder called "Debug". Go there and paste all the files. If you run the project now it will return more errors saying about more .dll files. Go to where you installed Mingw. In my case I had CodeBlocks with Mingw installed so it was at "C:\Program Files (x86)\CodeBlocks\MinGW". You should see a bin folder click on that. There's a LOT of files. Look for two dll's. Called libstdc++-6.dll and libgcc_S_sjlj-1.dll. Copy them both into the your SFML project's debug folder. If you run the project now it should work!


Finish!
Now, your finished getting SFML 2.3.1 to work with CodeLite 8.1. Go build some amazing SFML applications!

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Tutorial :: Installing SFML with CodeLite IDE
« Reply #1 on: August 18, 2015, 06:29:55 pm »
Since this isn't really a "discussion", I think this would be much better in the tutorials section of the Wiki.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Hydra

  • Newbie
  • *
  • Posts: 37
    • View Profile
Re: Tutorial :: Installing SFML with CodeLite IDE
« Reply #2 on: August 18, 2015, 07:36:06 pm »
Since this isn't really a "discussion", I think this would be much better in the tutorials section of the Wiki.

This is what the SFML page says:

General discussions
For everything that is not a help request

This isn't a help request

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Tutorial :: Installing SFML with CodeLite IDE
« Reply #3 on: August 18, 2015, 08:19:50 pm »
I wasn't saying it didn't deserve to be here. I was saying that it does deserve to be on the Wiki.

Pages on the Wiki don't automatically change over time but threads on the forum get lost rather quickly. Then, after adding it to the Wiki, there's always a dedicated forum for discussions about Wiki stuff!

Plus, there's an actual Tutorials section on the Wiki.

I was suggesting the Wiki because it's in your - and all of the people you're trying to help's - best interests.

Remember, if you post in the forum, you should expect people to voice their opinions - it's for discussions. I was just voicing mine  :)
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Tutorial :: Installing SFML with CodeLite IDE
« Reply #4 on: August 18, 2015, 09:05:27 pm »
The wiki also lets people add fixes and corrections easily. I agree that the wiki would probably be the best place for something like this.

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Re: Tutorial :: Installing SFML with CodeLite IDE
« Reply #5 on: August 20, 2015, 02:03:25 pm »
Well, you can discuss the overall article/idea here, then, once you think most people are happy, push it to the wiki, so everyone can refine it (once the basic outline is done).

TheOnlyWRT

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Tutorial :: Installing SFML with CodeLite IDE
« Reply #6 on: July 15, 2018, 01:04:25 am »
Hello all,

I am on a Mac and keep getting the following error after following the directions in the above guide:

dyld: Library not loaded: @rpath/libsfml-graphics.2.5.dylib
  Referenced from: /Users/willbur/Desktop/School/CompSci142/SFML-Demo/Debug/SFML-Demo
  Reason: image not found
Abort trap: 6

Does anyone know how to fix this? The codelite version is the 2.5 MacOS Clang. Thanks!

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: Tutorial :: Installing SFML with CodeLite IDE
« Reply #7 on: July 20, 2018, 09:15:26 am »
As the error says, `libsfml-graphics.2.5.dylib` isn't found. Make sure you've installed SFML and setup your project correctly.
SFML / OS X developer

 

anything