Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Recently i've just built an SFML/C++ project on Visual Studio Code using CMake and MinGW.I've successfully compiled and run a test file in my project folder.

Here's my Makefile:

StarFire:
	g++ main.cpp -o main.exe -DSFML_STATIC	-I F:\SFMLPrj\StarFirestc\Prefixes\include	-L F:\SFMLPrj\StarFirestc\Prefixes\lib	-lsfml-graphics-s -lsfml-window-s -lsfml-system-s -lopengl32 -lwinmm -lgdi32 -lfreetype


But then when i include more files into the folder i don't know how to modify my Makefile to compile 2 or more files.

Basically when i run my test file for the first time,i include SFML header into that test file so when the compiler(MinGW) runs,it looks into the Makefile and know that i've included SFML headers there.But when i make a new class in the folder(Game.h and Game.cpp) i put the SFML into the 'Game.h' file then include it in the test file.

Not only i don't know how the compiler would look for SFML headers and libs from now on.I also don't know how it will look for the 'Game' class and a bunch of other classes i will make in the future.

Can anyone help me ?

What I have tried:

I've tried to link the project with 'CMakeList.txt' and somehow its even more confusing.
Posted
Updated 31-Dec-19 17:30pm

1 solution

Take a look here: CMake Tutorial — CMake 3.16.2 Documentation[^]. That should guide you in creating your CMakeList.txt file.
Are you sure you're using cmake, though? Generating a Makefile through cmake should produce a Makefile that is many lines long. In my case, even the simplest cmake script produces a Makefile over 170 lines long.
 
Share this answer
 
Comments
TankRockett 1-Jan-20 0:11am    
CMake was a littlebit complicated ,but i've managed to compile and link the project successfully.Thanks for the help!
Shao Voon Wong 1-Jan-20 4:30am    
If you have solved your problem, remember to mark your question as solved so that the poster who provided you the answer, can get some points.
TankRockett 1-Jan-20 4:59am    
How exactly can i do that ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900