DO NOT skip the MinGW or SFML steps, but any other steps you should be fine to skip as long as you have done them before. I don't recommend it though. For example, you may want to uninstall CMake and reinstall it, etc.
- From here: https://git-scm.com/download/win
- Run, and proceed throught install steps Be sure to select the option "Use Git and optional Unix tools from Command Prompt"
- Do not change any other values
- Git Bash will henceforth be called the terminal
- Pin Git Bash to taskbar
- From here: https://www.7-zip.org/a/7z1900-x64.exe
check that you do not have a
C:\MinGW
folder already. If you do, delete it
-
Use 7zip to extract to
C:\MinGW
Make sure the folder C:\MinGW now contains the bin folder. if it contains the i686... folder instead, go into that folder, into the mingw folder, and copy all the folders in there. Then paste them in the parent of C:\MinGW. Then delete the i686.. folder completely
-
Type
env
into windows search bar and select "Edit System Environment Variables" -
Select "Environment Variables"
-
In the second lower box, select "Path", then click "Edit"
-
Click "New", and type in
C:\MinGW\bin
-
Click "Ok", then "Ok", then "Ok"
- create a main.cpp file:
#include <iostream>
int main() {
std::cout << "hello world" << std::endl;
}
- Open the terminal and run
g++ main.cpp
./a.exe
- You should see "hello world" printed out. If not, stop and figure out why it is not working.
- From here: https://github.com/Kitware/CMake/releases/download/v3.15.3/cmake-3.15.3-win64-x64.msi
- Select the option that says "Add to system PATH for all users"
- Delete your old
a.exe
- Create a simple CMakeLists.txt:
cmake_minimum_required(VERSION 3.7)
add_executable(test main.cpp)
- Open the terminal and run
cmake -G "MinGW Makefiles" .
If you get an error referencing that you cannot have
sh.exe
in your path, look at where it is telling you thatsh.exe
is at, go there, and delete it. Idk what it does but it has not affected me yet so... ¯_(ツ)_/¯
- You should get a Makefile generated
- Run
make
If you get an error referencing that make is not a recognized command, install it here: http://gnuwin32.sourceforge.net/downlinks/make.php, then add that
bin/
folder to your path as well
- Run ./text.exe
- You should see "hello world" printed out. If not, stop and figure out why it is not working.
- From here: https://www.sfml-dev.org/files/SFML-2.5.1-windows-gcc-7.3.0-mingw-32-bit.zip
- Extract it to
C:\SFML
Again, make sure the folder C:\SFML now contains the bin folder. if it contains the SFML-2.5.1... folder instead, go into that folder, into the SFML folder, and copy all the folders in there. Then paste them in the parent of C:\SFML. Then delete the SFML-2.5.1.. folder completely
- Add
C:\SFML\bin
to your PATH - Add a new Environment Variable as
CPLUS_INCLUDE_PATH
and set it equal toC:\SFML\include\SFML
- Delete any previous files from testing
- The main.cpp file:
#include <SFML/Graphics.hpp>
int main() {
sf::RenderWindow window(sf::VideoMode(400, 400), "test window");
while(window.isOpen()) {
sf::Event event;
while(window.pollEvent(event)) {
if (event.type == sf::Event::Closed) {
window.close();
}
}
window.clear();
// Draw stuff here later ...
window.display();
}
}
- The CMakeLists.txt file:
cmake_minimum_required(VERSION 3.1)
project(test)
set(SFML_DIR "C:/SFML/lib/cmake/SFML")
find_package(SFML 2.5.1 COMPONENTS system window graphics audio network REQUIRED)
add_executable(test main.cpp)
target_link_libraries(test sfml-system sfml-window sfml-graphics sfml-audio sfml-network )
- Go to where these files are with your terminal and run:
cmake -G "MinGW Makefiles" .
make
./test.exe
- You should see a small black window pop up, and be able to 'X' out. If not, figure out what is wrong
gcc 6.x.x is not working with SFML 2.5.1 so I have switched to 12.2.0, now it's fine.
May be it will be helpful for others.