Skip to content

Installation Guide

This document describes how to install clibx on your system.

Table of Contents

System Requirements

  • C Compiler: GCC, Clang, or compatible (C99 or later)
  • Build Tools: make
  • Platform: Unix-like system (Linux, macOS, BSD)
  • POSIX path utilities for full functionality
  • x86_64 Linux for clibx_print.h

What You Need

Not all header files are required. Choose based on your needs:

  • clibx.h (core) - Main utilities: arrays, math, memory, strings, paths, hash maps, logging
  • Always needed if you want the library utilities

  • clibx_ll.h (optional) - Singly-linked list implementation

  • Only needed if you use linked lists
  • Requires: clibx.h

  • clibx_print.h (optional) - Lightweight printf via direct syscalls

  • Only needed if you want stdio-free printing
  • Independent module: works standalone without clibx.h
  • Platform: x86_64 Linux only

Quick Install: Single Headers (wget/curl)

Download only the headers you need:

Option 1: Just the core library

wget https://raw.githubusercontent.com/DavidBalishyan/clibx/refs/heads/main/clibx.h
# or
curl -O https://raw.githubusercontent.com/DavidBalishyan/clibx/refs/heads/main/clibx.h

Option 2: Core + Linked List

wget https://raw.githubusercontent.com/DavidBalishyan/clibx/refs/heads/main/clibx.h
wget https://raw.githubusercontent.com/DavidBalishyan/clibx/refs/heads/main/clibx_ll.h

Option 3: Just the printf module

wget https://raw.githubusercontent.com/DavidBalishyan/clibx/refs/heads/main/clibx_print.h

Option 4: Everything

wget https://raw.githubusercontent.com/DavidBalishyan/clibx/refs/heads/main/clibx.h
wget https://raw.githubusercontent.com/DavidBalishyan/clibx/refs/heads/main/clibx_ll.h
wget https://raw.githubusercontent.com/DavidBalishyan/clibx/refs/heads/main/clibx_print.h

Place downloaded files in your project directory or include path, then include them in your code:

#include "clibx.h"        /* Always include if using core features */
#include "clibx_ll.h"     /* Optional: only if using linked lists */
#include "clibx_print.h"  /* Optional: only if using syscall printf */

Compile with:

gcc -o myprogram myprogram.c -lm

System-wide Installation

Clone the repository and install to /usr/local:

git clone https://github.com/DavidBalishyan/clibx.git
cd clibx
sudo make install

This will: - Copy all headers to /usr/local/include/clibx/ - Install manpages to /usr/local/share/man/man3/

**Note:** You don't need to use all headers. See [What You Need](#what-you-need) for details.

Verify installation:

man clibx          # Main library reference
man clibx_ll       # Linked list API
man clibx_print    # Lightweight printf API

Custom Installation Prefix

To install to a custom location (useful for development or user-wide installation):

make install PREFIX=$HOME/.local

Or:

make install PREFIX=/opt/clibx

This allows installation without sudo to your personal directory.

Adding to Your PATH

If using a custom prefix, ensure the paths are accessible:

# For header files (in your compiler search path)
export CFLAGS="-I$HOME/.local/include"

# For manpages (in your man search path)
export MANPATH="$HOME/.local/share/man:$MANPATH"

Add these to your shell profile (.bashrc, .zshrc, etc.) for persistence.

Manual Installation

If you prefer to install without make, copy only the headers you need:

  1. Copy headers (choose what you need): ```bash # Core library (always needed if using core features) — installed as clibx.h mkdir -p /usr/local/include/clibx cp clibx.h /usr/local/include/clibx/clibx.h

# Optional: Linked list support — installed as ll.h cp clibx_ll.h /usr/local/include/clibx/ll.h

# Optional: Standalone printf via syscalls — installed as print.h cp clibx_print.h /usr/local/include/clibx/print.h ```

  1. Copy manpages (optional): bash cp man/man3/clibx.3 /usr/local/share/man/man3/ cp man/man3/clibx_ll.3 /usr/local/share/man/man3/ cp man/man3/clibx_print.3 /usr/local/share/man/man3/

Uninstallation

Remove installed files:

sudo make uninstall

Or with a custom prefix:

make uninstall PREFIX=$HOME/.local

Using in Your Projects

Method 1: Include Installed Headers

After system-wide installation, include only what you need:

#include <clibx/clibx.h>        /* Required if using core features */
#include <clibx/ll.h>           /* Optional: only if using linked lists */
#include <clibx/print.h>        /* Optional: independent syscall printf */

Compile normally:

gcc -o myprogram myprogram.c -lm  /* -lm for math functions */

Method 2: Local Include (No Installation)

Copy only the headers you need to your project:

# Just the core library
cp path/to/clibx.h .

# Or add linked lists
cp path/to/clibx.h path/to/clibx_ll.h .

# Or just the printf module (standalone)
cp path/to/clibx_print.h .

Include locally:

#include "clibx.h"        /* Required for core features */
#include "clibx_ll.h"     /* Optional: depends on clibx.h */
#include "clibx_print.h"  /* Optional: standalone, no dependencies */

Compile:

gcc -o myprogram myprogram.c -lm

Method 3: Specify Include Path

Include from a specific directory:

gcc -I/path/to/clibx/headers -o myprogram myprogram.c -lm

Building Examples

After installation, build and run the demonstration programs:

make          # Build all demos
./bin/main.demo      # Run main demo
./bin/ll.demo        # Run linked list demo
./bin/print.demo     # Run print demo

Installation Verification

Verify the installation by checking file locations:

# Check headers
ls -la /usr/local/include/clibx/

# Check manpages
ls -la /usr/local/share/man/man3/clibx*.3

# Read manpages
man clibx
man clibx_ll
man clibx_print

Troubleshooting

Headers not found during compilation

Ensure headers are in a location that your compiler searches:

# Check compiler include paths
gcc -v -E - < /dev/null 2>&1 | grep include

# Or try explicit include path
gcc -I/path/to/headers -o myprogram myprogram.c -lm

Manpages not found

Update your manpage database:

# For custom prefix
export MANPATH="$HOME/.local/share/man:$MANPATH"
man clibx

# System-wide
sudo mandb
man clibx

Compilation errors

Ensure you're using C99 or later:

gcc -std=c99 -o myprogram myprogram.c -lm

Link libm (required for math functions):

gcc -o myprogram myprogram.c -lm

Upgrading

To upgrade to a new version:

cd clibx
git pull origin main
sudo make install

Or reinstall to custom prefix:

make install PREFIX=$HOME/.local

Next Steps

After installation, read the documentation:

  • Main library: man clibx
  • Linked list: man clibx_ll
  • Print module: man clibx_print

Or check the README.md for comprehensive documentation and examples.