Compiling SDL C++ code with MinGW and Atom

Hello everyone.

I’m rather new to compiling my code as my previous coding experiences where web languages and Unity scripts (mostly JavaScript), so there are many things I’m trying to understand and it’s being kind of overwhelming (IDE, Compiler, Linker, Headers, libs, dinamically linked, makefile and all that).

Anyway, after many troubles, I managed to correctly set up the Atom text editor with the MinGW compiler (I prefer to use this over Microsoft Visual Studio, Codeblocks or other IDEs for the moment).
“Hello World” correctly outputs to the console after hitting “compile and run” in Atom.

Next, I tried to do a simple SDL program that creates a window and displays an image in its surface.

Even after adding the SDL lib and include files in the environment variable in Windows PATH, Atom could not compile when I clicked “compile and run”.

I still managed to compile the code by using the command prompt. With the command prompt I go to my project directory and type:

g++ main.cpp -IC:\Development\SDL2\include\SDL2 -LC:\Development\SDL2\lib -w -Wl,-subsystem,windows -lmingw32 -lSDL2main -lSDL2 -o name_of_my_exe

I found this online. This works, it correctly creates the executable files, and it executes exactly as expected; but I don’t really understand why I have to do this extra step and how to avoid it.
I see the cmd prompt commands are essentially manually pointing the g++ compiler to the header and lib files it needs, but why doesn’t it find them without specifying them since they are in the windows PATH?
Also, I was doing some searches and found out that to avoid using the cmd prompt every time I could create a Makefile… I tryed it but had no luck yet (still trying). Also, if I manage to create a working Makefile, how do I use it directly from the Atom editor? Is this possible?

Sorry for the noob questions and thank you for your patiece!

PATH is only for executables. For instance, g++ is in a directory that’s in your PATH, which is why you can just type “g++” instead of “C:\something\whatever\hello\g++.exe”