This project is a starting point for creating audio-visual animations using C and the raylib library.
src/: Contains all the C source code (.cfiles).build/: This directory is automatically created and will contain the compiled application. It is ignored by Git.Makefile: Defines how to compile and run the project..gitignore: Tells Git to ignore thebuild/directory.
This project uses a Makefile to simplify the development process. You don't need to write complex compiler commands manually.
To compile your C code and create the executable, open your terminal in the project's root directory and run:
makeThis command reads the Makefile, compiles all the .c files from the src/ directory, and places the final executable file inside the build/ directory.
After a successful build, you can run your application with:
make runThis will execute the compiled program. A window should appear on your screen. To close it, press the ESC key or click the window's close button.
If you want to delete all the compiled files from the build/ directory, you can run:
make cleanThis is useful for starting a fresh build.
Yes, when you use a library like raylib, you need to tell the compiler where to find its header files and how to link against its library files. However, the Makefile in this project handles this for you automatically using a tool called pkg-config.
Here's a breakdown of the flags used in the Makefile:
-
CFLAGS: These are the "Compiler Flags".-Wall -Wextra: These flags enable extra warnings from the compiler. They are good practice for catching potential bugs in your code.-I$(SRCDIR): This tells the compiler to look for header files (like.hfiles) inside thesrc/directory.`pkg-config --cflags raylib`: This is the most important part forraylib. Thepkg-configtool automatically finds the correct compiler flags needed forraylibon your system. This makes your project more portable.
-
LDFLAGS: These are the "Linker Flags".`pkg-config --libs raylib`: This command gets the necessary flags to "link" your program with therayliblibrary files, which contain the actualraylibfunctions.
Because the Makefile is already set up with these commands, you don't have to worry about managing these flags yourself. You can just focus on writing your C code and use the simple make commands to handle the rest.