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
Using xmake (Recommended)
xmake is the recommended build system for Crest.
Install xmake
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:
Using Conan
Install Conan
Add Crest Dependency
Create or update conanfile.txt
:
Install Dependencies
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
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
Build with xmake
Build with CMake
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
- Install Visual Studio 2019 or later with C++ support
- Install xmake from xmake.io
- Clone the repository:
- Build:
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:
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:
Link Errors on Windows
Ensure you're linking against the correct Windows libraries:
Permission Denied on Linux/macOS
Use sudo
for system-wide installation:
Or install to a user directory:
Next Steps
- Read the Quick Start Guide
- Explore the C API Documentation
- Check out the C++ API Documentation
- View Examples