Skip to main content

Prerequisites

Before building Fract’ol, ensure you have the following dependencies installed on your system:

GCC Compiler

GNU Compiler Collection for compiling C code

Make

Build automation tool for running the Makefile

MiniLibX

Graphics library for creating windows and handling events

X11 Libraries

X Window System libraries (libX11, libXext)

Installing Dependencies

sudo apt-get update
sudo apt-get install gcc make libx11-dev libxext-dev libbsd-dev
The MiniLibX library is included in the project as a submodule (minilibx-linux/) and will be built automatically during compilation.

Installation Steps

1

Clone the Repository

Clone the Fract’ol repository to your local machine:
git clone https://github.com/yourusername/fractol.git
cd fractol
2

Initialize MiniLibX Submodule

If MiniLibX is included as a git submodule, initialize and update it:
git submodule init
git submodule update
If the minilibx-linux/ directory is already present, you can skip this step.
3

Build the Project

Compile the project using the provided Makefile:
make
This command will:
  • Compile the MiniLibX library in minilibx-linux/
  • Compile all C source files (*.c) in the project directory
  • Link against required libraries: -lmlx -lm -lX11 -lXext
  • Generate the fractol executable
cc -Wall -Wextra -Werror -c main.c -o main.o
cc -Wall -Wextra -Werror -c fractol_init.c -o fractol_init.o
cc -Wall -Wextra -Werror -c fractol_render.c -o fractol_render.o
cc -Wall -Wextra -Werror -c events.c -o events.o
cc -Wall -Wextra -Werror -c math_utils.c -o math_utils.o
cc -Wall -Wextra -Werror -c string_utils.c -o string_utils.o
cc -Wall -Wextra -Werror -o fractol main.o fractol_init.o fractol_render.o events.o math_utils.o string_utils.o -Lminilibx-linux/ -lmlx -lm -lX11 -lXext
4

Verify Installation

Confirm the executable was created successfully:
ls -l fractol
You should see the fractol executable file in your project directory.

Makefile Targets

The project includes several useful Makefile targets:
make
# or
make all
TargetDescription
make or make allBuilds MiniLibX and compiles the fractol executable
make cleanRemoves all object files (*.o)
make fcleanRemoves object files and the executable
make rePerforms a full rebuild (fclean + all)

Compiler Flags

The project is compiled with strict warning flags to ensure code quality:
-Wall -Wextra -Werror
  • -Wall: Enable all common warnings
  • -Wextra: Enable extra warnings not covered by -Wall
  • -Werror: Treat all warnings as errors

Troubleshooting

Common build issues and their solutions:

MiniLibX Build Fails

Problem: Error building MiniLibX library Solution: Ensure X11 development libraries are installed:
sudo apt-get install libx11-dev libxext-dev

Missing Math Library

Problem: Undefined references to sqrt, pow, or other math functions Solution: The Makefile already includes -lm flag. Ensure your system has the math library:
ldconfig -p | grep libm

Permission Denied

Problem: Cannot execute ./fractol Solution: Make the executable file executable:
chmod +x fractol

Linking Errors with X11

Problem: Cannot find -lX11 or -lXext Solution: Install X11 extension libraries:
# Ubuntu/Debian
sudo apt-get install libxext-dev

# Fedora/RHEL
sudo dnf install libXext-devel

Compilation Warnings as Errors

Problem: Build fails due to warnings being treated as errors (-Werror) Solution: Fix the warnings in the source code. The strict flags ensure high code quality. If necessary for testing, you can temporarily modify the CFLAGS in the Makefile:
CFLAGS = -Wall -Wextra
# Removed -Werror temporarily
It’s recommended to fix warnings rather than disable -Werror to maintain code quality.

Next Steps

Now that you have successfully built Fract’ol, proceed to the Quickstart Guide to learn how to run and interact with the fractal explorer.

Build docs developers (and LLMs) love