Installation Guide¶
Complete installation instructions for the Disjoint Interval Set library.
Overview¶
DIS is a header-only library with zero dependencies. Installation simply involves making the headers available to your compiler.
Requirements¶
Compiler Requirements¶
- C++17 or later (uses
std::optional
,std::ranges
concepts, structured bindings) - One of the following compilers:
- GCC 9.0 or later
- Clang 10.0 or later
- MSVC 2019 (19.20) or later
- Apple Clang 12.0 or later
Operating Systems¶
Tested on:
- Linux (Ubuntu 20.04+, Fedora 33+, Arch Linux)
- macOS 11.0+ (Big Sur and later)
- Windows 10/11 (with MSVC or MinGW-w64)
- FreeBSD 13.0+
Dependencies¶
None! DIS has zero external dependencies beyond the C++ standard library.
Installation Methods¶
Method 1: Copy Headers (Simplest)¶
The fastest way to start using DIS:
# Clone the repository
git clone https://github.com/yourusername/disjoint_interval_set.git
# Copy headers to your project's include directory
cp -r disjoint_interval_set/include/dis /path/to/your/project/include/
Then include in your code:
#include <dis/dis.hpp> // Main header (includes everything)
// Or include specific components
#include <dis/core/interval.hpp>
#include <dis/core/disjoint_interval_set.hpp>
Method 2: Git Submodule¶
For projects using Git:
# Add DIS as a submodule
git submodule add https://github.com/yourusername/disjoint_interval_set.git external/dis
git submodule update --init --recursive
With CMake¶
# CMakeLists.txt
cmake_minimum_required(VERSION 3.14)
project(MyProject)
# Add DIS include directory
include_directories(external/dis/include)
# Your executable
add_executable(my_app main.cpp)
target_compile_features(my_app PRIVATE cxx_std_17)
With Makefile¶
# Makefile
CXX = g++
CXXFLAGS = -std=c++17 -Wall -O2
INCLUDES = -Iexternal/dis/include
my_app: main.cpp
$(CXX) $(CXXFLAGS) $(INCLUDES) main.cpp -o my_app
Method 3: System-Wide Installation¶
Install headers system-wide (requires root):
Linux/macOS¶
# Clone repository
git clone https://github.com/yourusername/disjoint_interval_set.git
cd disjoint_interval_set
# Install to /usr/local/include
sudo cp -r include/dis /usr/local/include/
# Or to a custom prefix
PREFIX=$HOME/.local
mkdir -p $PREFIX/include
cp -r include/dis $PREFIX/include/
Windows (Administrator PowerShell)¶
# Clone repository
git clone https://github.com/yourusername/disjoint_interval_set.git
cd disjoint_interval_set
# Copy to MSVC include directory
$VS_PATH = "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\<version>\include"
Copy-Item -Recurse include\dis "$VS_PATH\dis"
Method 4: Package Managers¶
Conan (Coming Soon)¶
vcpkg (Coming Soon)¶
Verification¶
Test Installation¶
Create test.cpp
:
#include <dis/dis.hpp>
#include <iostream>
int main() {
using namespace dis;
auto interval = real_interval::closed(0, 10);
std::cout << "Interval: " << interval << '\n';
std::cout << "Contains 5: " << std::boolalpha << interval.contains(5) << '\n';
return 0;
}
Compile and run:
# GCC/Clang
g++ -std=c++17 test.cpp -o test
./test
# Expected output:
# Interval: [0,10]
# Contains 5: true
Run Test Suite¶
To verify the installation with the full test suite:
# Clone repository
git clone https://github.com/yourusername/disjoint_interval_set.git
cd disjoint_interval_set
# Build tests
mkdir build && cd build
cmake ..
make
# Run tests
ctest --verbose
Expected output:
Test project /path/to/build
Start 1: test_interval_comprehensive
1/3 Test #1: test_interval_comprehensive ...... Passed 0.05 sec
Start 2: test_dis_comprehensive
2/3 Test #2: test_dis_comprehensive ........... Passed 0.08 sec
Start 3: test_elegant_api
3/3 Test #3: test_elegant_api ................. Passed 0.03 sec
100% tests passed, 0 tests failed out of 3
IDE Setup¶
Visual Studio Code¶
Create .vscode/c_cpp_properties.json
:
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"${workspaceFolder}/external/dis/include"
],
"defines": [],
"compilerPath": "/usr/bin/g++",
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "linux-gcc-x64"
}
],
"version": 4
}
CLion¶
CMake configuration is automatically detected from CMakeLists.txt
.
Visual Studio¶
- Open project properties
- Go to C/C++ → General → Additional Include Directories
- Add path to
dis/include
- Go to C/C++ → Language → C++ Language Standard
- Set to ISO C++17 or later
Xcode¶
- Select target → Build Settings
- Search for "Header Search Paths"
- Add path to
dis/include
- Search for "C++ Language Dialect"
- Set to C++17 or later
Build System Integration¶
CMake¶
cmake_minimum_required(VERSION 3.14)
project(MyProject CXX)
# Option 1: Add as subdirectory (if using git submodule)
add_subdirectory(external/dis)
# Option 2: Find installed package
find_package(dis REQUIRED)
# Your target
add_executable(my_app src/main.cpp)
target_link_libraries(my_app PRIVATE dis::dis)
target_compile_features(my_app PRIVATE cxx_std_17)
Meson¶
project('myproject', 'cpp',
default_options: ['cpp_std=c++17'])
dis_dep = declare_dependency(
include_directories: include_directories('external/dis/include'))
executable('my_app',
sources: 'main.cpp',
dependencies: [dis_dep])
Bazel¶
# WORKSPACE
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
git_repository(
name = "dis",
remote = "https://github.com/yourusername/disjoint_interval_set.git",
tag = "v1.0.0",
)
# BUILD
cc_binary(
name = "my_app",
srcs = ["main.cpp"],
deps = ["@dis//:dis"],
)
Advanced Configuration¶
Compiler Flags¶
Optimization¶
# Development (fast compilation, debug info)
g++ -std=c++17 -O0 -g main.cpp
# Release (maximum optimization)
g++ -std=c++17 -O3 -DNDEBUG main.cpp
# With native CPU optimizations
g++ -std=c++17 -O3 -march=native main.cpp
Warnings¶
# Recommended warning flags
g++ -std=c++17 -Wall -Wextra -Wpedantic main.cpp
# Stricter warnings
clang++ -std=c++17 -Weverything -Wno-c++98-compat main.cpp
Custom Namespace¶
By default, all DIS symbols are in the dis
namespace. To avoid conflicts:
// Option 1: Use namespace alias
namespace my_dis = dis;
// Option 2: Selective imports
using dis::real_interval;
using dis::real_set;
Static vs Dynamic Linking¶
DIS is header-only, so there's no choice between static and dynamic linking. However, if you create a wrapper library:
# Create a static library wrapper (optional)
add_library(dis_wrapper STATIC src/dis_wrapper.cpp)
target_include_directories(dis_wrapper PUBLIC external/dis/include)
target_compile_features(dis_wrapper PUBLIC cxx_std_17)
Troubleshooting¶
Common Issues¶
Issue: "dis/dis.hpp: No such file or directory"¶
Solution: Ensure include path is set correctly:
# Check include path
g++ -std=c++17 -I./include test.cpp
# Or for system-wide installation
g++ -std=c++17 -I/usr/local/include test.cpp
Issue: C++17 features not available¶
Solution: Explicitly enable C++17:
Issue: Linker errors with std::optional¶
Solution: On some older systems, may need to link against C++ filesystem library:
Issue: Slow compilation times¶
Solutions:
- Use precompiled headers
- Include only what you need:
- Enable ccache:
Platform-Specific Issues¶
macOS: Xcode Command Line Tools¶
Ensure Xcode CLT are installed:
Windows: MinGW PATH Issues¶
Add MinGW to PATH:
Linux: Old GCC Version¶
Update GCC on Ubuntu/Debian:
Next Steps¶
Once installed, proceed to:
- Getting Started Guide: Your first program
- API Reference: Detailed documentation
- Examples: Real-world use cases
Uninstallation¶
To remove DIS: