Skip to content

Installation Guide

This guide covers multiple ways to install and use Crest in your projects.

Prerequisites

  • C++20 compatible compiler (GCC 10+, Clang 12+, MSVC 2019+)
  • C17 compatible compiler for C projects
  • CMake 3.15+ or xmake 2.8.0+

Installation Methods

xmake is the recommended build system for Crest.

Install xmake

curl -fsSL https://xmake.io/shget.text | bash
Invoke-Expression (Invoke-Webrequest 'https://xmake.io/psget.text' -UseBasicParsing).Content

Add Crest to Your Project

In your xmake.lua:

add_requires("crest")

target("your_app")
    set_kind("binary")
    add_packages("crest")
    add_files("src/*.cpp")

Then build:

xmake build

Using Conan

Install Conan

pip install conan

Add Crest Dependency

Create or update conanfile.txt:

[requires]
crest/0.0.0

[generators]
CMakeDeps
CMakeToolchain

Install Dependencies

conan install . --build=missing

CMakeLists.txt

cmake_minimum_required(VERSION 3.15)
project(MyApp)

find_package(crest REQUIRED)

add_executable(my_app src/main.cpp)
target_link_libraries(my_app crest::crest)

Using vcpkg

Install vcpkg

git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.sh
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
.\bootstrap-vcpkg.bat

Install Crest

./vcpkg install crest

CMakeLists.txt

cmake_minimum_required(VERSION 3.15)
project(MyApp)

find_package(crest CONFIG REQUIRED)

add_executable(my_app src/main.cpp)
target_link_libraries(my_app PRIVATE crest::crest)

Build from Source

Clone Repository

git clone https://github.com/muhammad-fiaz/crest.git
cd crest

Build with xmake

xmake config -m release
xmake build
xmake install

Build with CMake

mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build .
sudo cmake --install .

Platform-Specific Instructions

Linux

Ubuntu/Debian

# Install dependencies
sudo apt update
sudo apt install build-essential git

# Install xmake
curl -fsSL https://xmake.io/shget.text | bash

# Clone and build
git clone https://github.com/muhammad-fiaz/crest.git
cd crest
xmake build
sudo xmake install

Fedora/RHEL

# Install dependencies
sudo dnf install gcc-c++ git

# Install xmake
curl -fsSL https://xmake.io/shget.text | bash

# Clone and build
git clone https://github.com/muhammad-fiaz/crest.git
cd crest
xmake build
sudo xmake install

Windows

Using Visual Studio

  1. Install Visual Studio 2019 or later with C++ support
  2. Install xmake from xmake.io
  3. Clone the repository:
    git clone https://github.com/muhammad-fiaz/crest.git
    cd crest
    
  4. Build:
    xmake config -m release
    xmake build
    xmake install
    

Using MSYS2/MinGW

# Install dependencies
pacman -S mingw-w64-x86_64-gcc git

# Install xmake
curl -fsSL https://xmake.io/shget.text | bash

# Clone and build
git clone https://github.com/muhammad-fiaz/crest.git
cd crest
xmake build
xmake install

macOS

# Install Xcode Command Line Tools
xcode-select --install

# Install xmake
curl -fsSL https://xmake.io/shget.text | bash

# Clone and build
git clone https://github.com/muhammad-fiaz/crest.git
cd crest
xmake build
sudo xmake install

Verify Installation

Create a test file test.cpp:

#include "crest/crest.hpp"
#include <iostream>

int main() {
    std::cout << "Crest version: " << crest::VERSION << std::endl;

    crest::App app;
    app.get("/", [](crest::Request& req, crest::Response& res) {
        res.json(200, R"({"status":"ok"})");
    });

    std::cout << "Starting server on http://127.0.0.1:8000" << std::endl;
    app.run("127.0.0.1", 8000);

    return 0;
}

Build and run:

xmake build
xmake run
mkdir build && cd build
cmake ..
cmake --build .
./test

Visit http://127.0.0.1:8000 to verify the server is running.

Troubleshooting

Compiler Not Found

Ensure you have a C++20 compatible compiler installed:

# Check GCC version (should be 10+)
g++ --version

# Check Clang version (should be 12+)
clang++ --version

xmake Not Found

Add xmake to your PATH:

export PATH=$HOME/.local/bin:$PATH

Add %USERPROFILE%\.local\bin to your PATH environment variable.

Ensure you're linking against the correct Windows libraries:

if is_plat("windows") then
    add_syslinks("ws2_32", "mswsock")
end

Permission Denied on Linux/macOS

Use sudo for system-wide installation:

sudo xmake install

Or install to a user directory:

xmake install --prefix=$HOME/.local

Next Steps

Getting Help