1.Go to https://7-zip.org/download.html and download the 64 bit version or 32 bit if that's how your PC/laptop is running.
2.These next parts have to be done so this can work correctly with cmake. Go to https://www.sfml-dev.org/download/sfml/2.5.1/ and download both these files.
If you like to see any image copy and paste the link to see through out this post.
3.It does not matter if you have minGW already installed it is a more updated version so it won’t work(version 9.0) so the SFML website links you to download the 64 bit 6.0 version.
4.Then go to download and install 7 zip then unzip both file you installed from sfml and extract files like in this picture make sure you do it in downloads or you won’t be able to do it because of permissions if this happens try “Extract here” options from 7 zip.
5.After both the minGW and sfml files have been extracted click once into each file and cut or move the file to your main disk of your laptop/PC make sure you move the folder inside of the folder you downloaded so the paths can be correct later.
6.Then remember the name of the minGW(most likely mingw64) compiler you downloaded and rename the SFML2.5.1 folder to SFML will make our lives easier later.
7.Open a project if you name it minesweeper you can copy the code for Cmake directly and now we have to check or change the minGW clion is working on so CRTL+ALT+S in clion to get to settings go to Build, Execution, Deployment tab then inside of that click on toolchains and change your Toolset to the mingw64 or whatever you named it so clion can start using it and apply and press ok.
8.Almost done in your project make a main.cpp and configure cmake. Then after that is done go to CMakeLists.txt to add the sfml library and copy and paste this code exactly it is very specific.
find_package(SFML COMPONENTS system window graphics audio network REQUIRED)
target_link_libraries(minesweeper sfml-system sfml-window sfml-graphics sfml-audio)
9.If you didn’t name the folder minesweeper replace minesweeper in the code above to whatever the name of you folder is.
10.Then reload your cmake to update the changes and go to you main to test that it works and copy and paste this basic program to see if it works.
where it saids include in bold look at the picture to see what goes there because doesn't allow <> form some reason.
sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
if (event.type == sf::Event::Closed)
11.Run the program and a small green dot sure pop up on your screen. If it didn’t ethier you have the wrong version of mingGW or named something wrong.
Top comments (0)