Search code examples
c++sfml2d-gamescodelite

How to configure CodeLite IDE to use C++ and SFML library? (Windows/Linux) Configuration complete solution


How to configure "CodeLite" IDE for being able to develop in C++ with the library SFML?

Here below is my complete solution...

ENJOY


Solution

  • This complete solution is described within Windows but this also works in Linux

    1) Downloads on SFML Website (Download section) :

    https://www.sfml-dev.org/download/sfml/2.5.1/

    • The needed compiler
    • The corresponding SFML libraries

    enter image description here

    Pay attention to :

    1. The compiler name (here MinGW)
    2. The compiler version (here 7.3.0)
    3. The compiler target environment (here 32 bits)

    The compiler and the version of SFML have to match 100%!!!

    2) Copy the compiler directory and the SMFL directory on your hard disk

    enter image description here

    3) Define the compiler in CodeLite

    From top menu "Settings/Build Settings..."

    enter image description here

    4) Create your project

    enter image description here

    5) Define project's compiler

    1. Right click on the project

    2. Choose "Settings..."

    3. In section General -> choose the compiler

    enter image description here

    6) Compiler settings (within the project)

    In "Compiler" section ...

    1. Define "Include Paths" = C:\SFML-2.5.1\include

    2. "Preprocessors" = SFML_STATIC

    enter image description here

    7) Linker settings (within the project)

    In "Linker" section ...

    1. Define "Libraries Search Path" = C:\SFML-2.5.1\lib

    2. "Libraries" =

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

    enter image description here


    enter image description here

    8) Add the following code to the project (for testing purpose)

    
    #include <SFML/Graphics.hpp>
    
    int main()
    {
    sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
    sf::CircleShape shape(100.f);
    shape.setFillColor(sf::Color::Green);
    
    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }
    
        window.clear();
        window.draw(shape);
        window.display();
    }
    
    return 0;
    
    
    }
    

    9) Compile the project

    This will not compile cause you have to copy/paste some .dll files into the compilation folder

    10) Add Dlls to the bin directory

    enter image description here

    1. The executable compiled

    2. File "libstdc++-6.dll" from "C:\mingw32\bin"

    3. All Dlls from "C:\SFML-2.5.1\bin"

    INFO : some additionnal .dll files would be needed (eventually some from /bin of the compiler directory)

    11) Recompile

    12) Execute

    If it works...

    enter image description here

    13) Enjoy!!!