π¨π½βπ³ Basic project template for general C projects. Made for the 42 curriculum and with β€οΈ
$ git clone --recursive [email protected]:RubenNijhuis/Basic-C-Template.git
$ make run
Et voila, a main.c outputting a welcome message
Some of the next steps could be changing the name of the project. Which you can do in the General Variables
section of the Makefile.
This project uses my personal libraries, in case you want to use your own I recommend learning some stuff about git submodules here
However the Makefile
specifically supports my project/library structure. This WILL be an issue if your library structure differs. Mine works like this.
- A library has two major components.
- There is an include folder where the
.h
files can be found. - The
.a
file must be in the root of the directory
- There is an include folder where the
- The makefile is in the root of the project
In short the structure should match something like this.
| root
| include/
| .h files
| Makefile
| archive.a
But don't worry. Anyone with a basic understanding of Makefiles should be able to change the paths that are in the input files
section of the makefile.
My expertise lies with Web Development so my use of the makefile might be a bit crude as to what the standards are. My apologies for this but I felt like providing a source like this will help anyone who still has issues with structuring their project. A small bits help right?
This project is structure in a way that I prefer working with. It's a mix of working in JavaScript projects and some other languages where folder structure dictates code relation. If you have improvements or other comments you can open an issue.
Due to the way the makefile is made you have to explicitely name each file in your makefile. (this will change in an update soon btw). Furthermore .o
files are put in a objs/
folder to keep the src/
clean.
/- Basic-C-Template
/- assets
# Any assets like images or text files can be put here
/- include
# files like .a or .h can be put here
/- libs
# included libraries like libft or get_next_line are put here
/- src
# your project files can be ordered here
.gitignore # i really shouldn't have to explain this
LICENS # mit licens for license reasons
Makefile # magic happens here
README.md # the file that contains what you are currently reading
Pipex - https://github.com/RubenNijhuis/Pipex
Philosophers - https://github.com/RubenNijhuis/Philosophers
So Long - https://github.com/RubenNijhuis/So-Long
Push Swap - https://github.com/RubenNijhuis/Push-Swap
MiniShell - https://github.com/mjoosten42/minishell