This is a boilerplate for a C++ project.
Have a quick look at system requirements. please refer to requirements.md.
Have a quick look at menu interfaces. please refer to console-menu-interfaces.md.
Have a quick look at UML class Diagram. please refer to cpp-library-system-uml.pdf.
Ensure you have the following tools installed on your system:
-
C++ Compiler and Build Tools
You can install either
build-essential
(which includesg++
) org++
directly.-
Option 1: Install
build-essential
:sudo apt update sudo apt install build-essential
-
Option 2: Install
g++
directly:sudo apt update sudo apt install g++
-
-
GDB (GNU Debugger)
sudo apt install gdb
-
CMake
sudo apt install cmake
-
clang-format
sudo apt install clang-format
-
Visual Studio Code with the following extensions:
- C/C++ by Microsoft
- CMake Tools by Microsoft
To install the C/C++ extension:
- Open Visual Studio Code.
- Go to Extensions view by pressing
Ctrl+Shift+X
. - Search for
C/C++
by Microsoft and click Install.
To install the CMake Tools extension:
- Open Visual Studio Code.
- Go to Extensions view by pressing
Ctrl+Shift+X
. - Search for
CMake Tools
by Microsoft and click Install.
To compile the project, use the make
command. This will generate the executable file in the output
directory.
make
To run the compiled executable, use the make run command. This will compile the project (if necessary) and then run the executable.
make run
To clean up the build files, including object files and the executable, use the make clean command.
make clean
Make sure you have installed GDB on your system. To debug the project.
-
Compile the project with debugging symbols.
make
-
Run
gdb
with the executable.gdb ./output/main
-
Inside gdb, set breakpoints and run the program:
(gdb) break main (gdb) run
-
Use typical gdb commands to step through the code, inspect variables, etc.
(gdb) step (gdb) print variable_name
We can also debug the project using Visual Studio Code. To do this, follow these steps:
- Open the project in Visual Studio Code.
- Open the file you want to debug.
- Set breakpoints by clicking on the left margin of the editor window.
- Press
F5
to start debugging. - Use shortcuts like
F10
to step over,F11
to step into, etc. - Use the debug panel on the left to inspect variables, call stack, etc.
The project has the following file structure:
src/
: Contains the source files (.cpp
).include/
: Contains the header files (.hpp
).output/
: Contains the compiled executable.lib/
: Contains third-party libraries (.a
, etc...)Makefile
: Contains the build, run, clean, and debug commands..clang-format
: Contains the formatting style for clang-format..vscode/
: Contains the Visual Studio Code settings and configurations for C++.docs/:
Contains the project documentation.
This project is for educational purposes only. It was created as part of a course on C++ programming by Dr. Mostafa Saad Ibrahim on Udemy