Skip to main content

Requirements

Before installing Tabular, ensure you have:
  • C++ Compiler: Supporting C++11 or later
  • CMake: Version 3.15 or higher (for CMake installation method)
  • Platform: Linux, macOS, or Windows

Installation Methods

Tabular offers two installation methods to fit your project needs:

CMake Installation

Full CMake integration with package configuration

Header-Only Include

Direct include for quick setup

Method 1: CMake Installation

1

Clone the repository

First, clone the Tabular repository to your local machine:
git clone https://github.com/Anas-Hamdane/tabular.git
cd tabular
2

Configure the project

Create a build directory and configure the project with CMake:
mkdir build
cd build
cmake ..
The CMakeLists.txt configures Tabular as an interface library:
cmake_minimum_required(VERSION 3.15)
project(tabular
        VERSION 1.5.2
        DESCRIPTION "lightweight, header-only C++ library for creating well-formatted, fully-customizable CLI tables."
        LANGUAGES CXX)

add_library(tabular INTERFACE)
add_library(tabular::tabular ALIAS tabular)

target_compile_features(tabular INTERFACE cxx_std_11)
target_include_directories(tabular INTERFACE
        $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
        $<INSTALL_INTERFACE:include>
)
3

Install the library

Install Tabular to your system:
sudo cmake --install .
This installs:
  • Header files to ${CMAKE_INSTALL_INCLUDEDIR}/tabular
  • CMake config files to ${CMAKE_INSTALL_LIBDIR}/cmake/tabular
4

Use in your CMake project

Add Tabular to your project’s CMakeLists.txt:
find_package(tabular 1.5.2 REQUIRED)

add_executable(my_app main.cpp)
target_link_libraries(my_app PRIVATE tabular::tabular)

Method 2: Header-Only Include

For a quick setup without CMake, you can directly include the header files in your project.
1

Choose your include method

You have two options:Option A: Single-header file (Recommended for simplicity)Download and include the single-header file:
wget https://raw.githubusercontent.com/Anas-Hamdane/tabular/master/single_include/tabular/tabular.h
Option B: Multiple header filesCopy the entire include/tabular directory to your project.
2

Include in your code

For the single-header approach:
#include "tabular.h"
For multiple headers:
#include "tabular/table.h"
#include "tabular/render.h"
3

Compile your code

Compile with C++11 or later:
g++ -std=c++11 main.cpp -o my_app
Or with clang:
clang++ -std=c++11 main.cpp -o my_app
Tabular is a header-only library, so there’s no need to link against any compiled libraries. Just include the headers and you’re ready to go!

Verify Installation

Create a simple test file to verify your installation:
#include "tabular/table.h"
#include "tabular/render.h"

int main()
{
  using namespace tabular;
  Table table;
  
  table.addRow({"Hello", "Tabular!"});
  
  render(table.str() + '\n', stdout);
  return 0;
}
Compile and run:
g++ -std=c++11 test.cpp -o test
./test
If you see a formatted table, the installation was successful!

Next Steps

Quick Start Guide

Learn how to create your first table with a step-by-step tutorial

Build docs developers (and LLMs) love