Skip to main content

Build Targets

The Makefile provides the following targets:
make all

Compilation Process

1

Build both executables

Run the default target to compile both server and client:
make
This executes make all, which builds both server and client executables.
2

Compilation details

The Makefile uses the following compiler configuration:
CC = gcc
FLAGS = -Wextra -Werror -Wall
Both executables are compiled with strict warning flags that treat warnings as errors.
3

Verify the build

After successful compilation, you should see:
Preparing server...:
server created :)!
Preparing client...:
client created :)!
The executables server and client will be created in your current directory.

Dependencies

Both executables depend on utility functions from libft:
UTILS_SRC = libft/ft_printf.c libft/ft_write_pointer.c libft/ft_write_num.c \
            libft/ft_write_char.c libft/ft_write_str.c
These files provide:
  • ft_printf - Custom printf implementation
  • ft_write_pointer - Pointer formatting
  • ft_write_num - Number formatting
  • ft_write_char - Character output
  • ft_write_str - String output

Server Compilation

gcc -Wextra -Werror -Wall server.c libft/ft_printf.c libft/ft_write_pointer.c \
    libft/ft_write_num.c libft/ft_write_char.c libft/ft_write_str.c -o server

Client Compilation

gcc -Wextra -Werror -Wall client.c libft/ft_printf.c libft/ft_write_pointer.c \
    libft/ft_write_num.c libft/ft_write_char.c libft/ft_write_str.c -o client

Cleaning Build Files

make clean
Output:
Removing files ***.o:
Done :D!
This removes all .o files (server.o, client.o, and utility object files).

Troubleshooting

fatal error: ../libft/ft_printf.h: No such file or directory
Solution: Ensure the libft directory exists and contains all required files:
  • ft_printf.h
  • ft_printf.c
  • ft_write_pointer.c
  • ft_write_num.c
  • ft_write_char.c
  • ft_write_str.c
If you encounter warnings treated as errors due to -Werror, you have two options:
  1. Fix the warnings (recommended)
  2. Temporarily remove -Werror from the Makefile FLAGS (not recommended for production)
FLAGS = -Wextra -Wall
bash: ./server: Permission denied
Solution: The build process should create executable files automatically. If this error occurs:
chmod +x server client
If modifications to source files don’t seem to take effect:
make re
This performs a full rebuild from scratch.

Build Output Files

After running make, your directory will contain:
  • server - Server executable
  • client - Client executable
  • server.o - Server object file
  • client.o - Client object file
  • libft/*.o - Utility object files
The .o files can be removed with make clean while keeping the executables.

Build docs developers (and LLMs) love