Installation
This installation guide provides instructions on installing the C++ interface for dotjson
. For instructions on how to use dotjson
, please see the usage guide.
System Requirements
- x86_64 architecture
- Linux, preferably Ubuntu 24.04
- Clang++ or GCC with C++20 support
- GLIBC 2.38 or newer
Option 1: System-wide installation
For multi-project use, install the header files and shared libraries to the system paths.
Extract the distribution
# Create a directory for dotjson
mkdir dotjson
# Extract the provided archive
tar -xzvf dotjsoncpp-x.y.z.tar.gz -C dotjson
Install the library
# Create a .txt vendor directory, as well as the dotjson subdirectory
sudo mkdir -p /usr/local/include/dottxt/dotjson
# Install headers in the product-specific directory
sudo cp dotjson/include/dotjson.hpp /usr/local/include/dottxt/dotjson/
sudo cp dotjson/include/cxx.h /usr/local/include/dottxt/dotjson/
# Install shared libraries
sudo cp dotjson/lib/libdotjson.so /usr/local/lib/
sudo cp dotjson/lib/libdotjsoncpp.so /usr/local/lib/
sudo cp dotjson/lib/libdotgrammar.so /usr/local/lib/
# Update the dynamic linker cache
sudo ldconfig
Usage
Include the headers in your C++ code:
#include <dottxt/dotjson/dotjson.hpp>
#include <dottxt/dotjson/cxx.h>
Compile your program:
g++ -o yourprogram yourprogram.cpp -ldotjson -ldotjsoncpp -ldotgrammar -Wall -Wextra -std=c++20 -O3
Option 2: Project-local installation
dotjson
can be installed to local directories without administrator privileges, or in the case of single-project usage.
Extract the distribution
# Create directory to store .txt libraries
mkdir -p dottxt/dotjson
# Extract the provided archive directly into the dotjson subdirectory
tar -xzvf dotjsoncpp-x.y.z.tar.gz -C dottxt/dotjson
Compile your program
Include these headers in your code:
#include "dottxt/dotjson/include/dotjson.hpp"
#include "dottxt/dotjson/include/cxx.h"
Compile your program with the correct include and library paths:
g++ -o yourprogram yourprogram.cpp -I. -L./dottxt/dotjson/lib -ldotjson -ldotjsoncpp -ldotgrammar -Wall -Wextra -std=c++20 -O3 -Wl,-rpath,\$ORIGIN/dottxt/dotjson/lib
Note
The -rpath
flag ensures the runtime linker can find the shared libraries relative to your executable.