Prerequisites
Before installing Push Swap, ensure you have:On macOS, you can install the Xcode Command Line Tools to get all prerequisites:
Installation Steps
Clone the Repository
Download the source code to your local machine:Or download and extract the source files manually if you don’t have git.
Build the Project
Compile the source code using the Makefile:This command:
- Compiles all
.cfiles with strict flags (-Wall -Wextra -Werror) - Links object files into the final executable
- Creates the
push_swapbinary
Makefile Commands
The project includes several useful Make targets:make or make all
Builds the project (default target).
make clean
Removes object files (.o files) but keeps the executable.
make fclean
Removes all generated files including the executable.
make re
Rebuilds the project from scratch (equivalent to make fclean + make).
Use
make re when you want to ensure a completely fresh build, especially after modifying header files.Compilation Flags
The project is compiled with strict warning flags to ensure code quality:-Wall: Enable all common warnings-Wextra: Enable extra warnings not covered by-Wall-Werror: Treat all warnings as errors (compilation fails if warnings exist)
Project Structure
After building, your directory will contain:Troubleshooting
Error: 'cc' or 'gcc' command not found
Error: 'cc' or 'gcc' command not found
You need to install a C compiler.On Ubuntu/Debian:On macOS:On Fedora/RHEL:
Error: 'make' command not found
Error: 'make' command not found
Install GNU Make:On Ubuntu/Debian:On macOS:
Compilation errors or warnings
Compilation errors or warnings
The project uses strict compilation flags (
-Werror). If you see compilation errors:- Ensure you’re using a C99-compatible compiler
- Check that all source files are present
- Try a clean rebuild:
- Verify your compiler version is recent enough:
Permission denied when running ./push_swap
Permission denied when running ./push_swap
Make the binary executable:
Make completes but no executable is created
Make completes but no executable is created
Check for error messages during compilation. If the build appears successful but no executable exists:
- Verify all source files are present
- Check disk space:
df -h - Try rebuilding:
make re - Check the Makefile for the correct output name (should be
push_swap)
Uninstallation
To remove all compiled files:Next Steps
Quick Start
Learn how to use Push Swap with examples
Usage Examples
See common usage patterns and commands