Building TechKit from Source

This guide explains how to build TechKit from source code for different platforms and use cases.

Prerequisites

Required Tools

  • CMake: Version 3.14 or higher

  • C++ Compiler: C++11 compatible compiler

    • GCC: 5.0 or higher

    • Clang: 3.4 or higher

    • MSVC: Visual Studio 2015 or higher (Windows)

  • Git: For cloning the repository

Optional Dependencies

  • Python 3.10+: For building Python bindings

  • Emscripten: For building WebAssembly bindings

  • Catch2: Automatically downloaded by CMake for tests

Quick Start

Clone Repository

git clone https://github.com/yiivon/techkit.git
cd techkit

Build Native Library

# Create build directory
mkdir build && cd build

# Configure CMake
cmake .. -DCMAKE_BUILD_TYPE=Release

# Build (parallel build recommended)
cmake --build . --parallel

# Run tests (optional)
ctest --output-on-failure

Install (Optional)

cmake --install . --prefix /usr/local

Build Options

TechKit provides several CMake options to customize the build:

Option

Default

Description

TECHKIT_BUILD_SHARED

ON (standalone) / OFF (submodule)

Build shared library (.so/.dll/.dylib)

TECHKIT_BUILD_STATIC

ON

Build static library (.a/.lib)

TECHKIT_BUILD_TESTS

ON (standalone) / OFF (submodule)

Build unit tests

TECHKIT_BUILD_EXAMPLES

ON (standalone) / OFF (submodule)

Build example programs

TECHKIT_BUILD_VALIDATION

OFF

Build TA-Lib validation tests

TECHKIT_BUILD_PYTHON

OFF

Build Python bindings

TECHKIT_BUILD_WASM

OFF

Build WebAssembly bindings

TECHKIT_CXX_STANDARD

11

C++ standard (11, 14, 17, 20)

Example: Custom Build Configuration

cmake .. \
    -DCMAKE_BUILD_TYPE=Release \
    -DTECHKIT_BUILD_SHARED=ON \
    -DTECHKIT_BUILD_STATIC=OFF \
    -DTECHKIT_BUILD_TESTS=OFF \
    -DTECHKIT_BUILD_EXAMPLES=OFF \
    -DTECHKIT_CXX_STANDARD=17

Platform-Specific Instructions

Linux

# Install dependencies (Ubuntu/Debian)
sudo apt-get update
sudo apt-get install build-essential cmake git

# Build
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build . --parallel

# Install system-wide (optional)
sudo cmake --install . --prefix /usr/local

macOS

# Install dependencies via Homebrew
brew install cmake

# Build
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build . --parallel

Windows

Using Visual Studio

REM Open Developer Command Prompt
mkdir build
cd build
cmake .. -G "Visual Studio 17 2022" -A x64
cmake --build . --config Release

Using MinGW

# Install MinGW-w64 and CMake
mkdir build && cd build
cmake .. -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release
cmake --build .

Building Python Bindings

Prerequisites

  • Python 3.10 or higher

  • NumPy 1.21 or higher

  • pip and build tools

Development Installation

cd bindings/python
pip install -e .

Build Distribution Packages

cd bindings/python

# Install build tools
pip install build wheel

# Build wheel
python -m build --wheel

# Build source distribution (optional)
python -m build --sdist

Build for Multiple Platforms

Use cibuildwheel for cross-platform wheel building:

pip install cibuildwheel
cibuildwheel --platform linux

Building WebAssembly Bindings

Prerequisites

  1. Install Emscripten SDK:

git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
./emsdk install latest
./emsdk activate latest
source ./emsdk_env.sh

Build WASM

cd bindings/wasm

# Core edition (158 indicators)
mkdir build-core && cd build-core
emcmake cmake ../src/core
emmake make -j4

# Full edition (189 indicators)
cd ..
mkdir build-full && cd build-full
emcmake cmake ../src/full
emmake make -j4

Output Files

  • techkit-core.wasm - Core edition (~200KB)

  • techkit-full.wasm - Full edition (~800KB)

  • techkit-core.js - JavaScript bindings

  • techkit-full.js - JavaScript bindings

Running Tests

Unit Tests

cd build
ctest --output-on-failure

Run Specific Test

cd build
./tests/test_rsi

Validation Tests (TA-Lib Comparison)

# Build with validation enabled
cmake .. -DTECHKIT_BUILD_VALIDATION=ON
cmake --build .

# Run validation
cd validation
./techkit_validation

Building as Git Submodule

If TechKit is included as a submodule in your project:

# Add submodule
git submodule add https://github.com/yiivon/techkit.git libs/techkit

# Initialize and update
git submodule update --init --recursive

In your CMakeLists.txt:

# Add TechKit subdirectory
add_subdirectory(libs/techkit)

# Link to your target
target_link_libraries(your_app PRIVATE techkit::static)

Note: When building as a submodule, TECHKIT_BUILD_SHARED defaults to OFF and TECHKIT_BUILD_TESTS defaults to OFF to avoid conflicts.

Using Installed Package

If TechKit is installed system-wide:

find_package(TechKit REQUIRED)
target_link_libraries(your_app PRIVATE TechKit::techkit)

Troubleshooting

CMake Not Found

Error: CMake Error: Could not find CMAKE_ROOT

Solution: Install CMake 3.14 or higher:

  • Linux: sudo apt-get install cmake

  • macOS: brew install cmake

  • Windows: Download from cmake.org

Compiler Not Found

Error: No CMAKE_CXX_COMPILER could be found

Solution:

  • Linux: Install build-essential: sudo apt-get install build-essential

  • macOS: Install Xcode Command Line Tools: xcode-select --install

  • Windows: Install Visual Studio with C++ support

Python Bindings Build Fails

Error: Could not find Python3

Solution:

  • Ensure Python 3.10+ is installed and in PATH

  • Install Python development headers:

    • Linux: sudo apt-get install python3-dev

    • macOS: Included with Python

    • Windows: Included with Python installer

WASM Build Fails

Error: emcmake: command not found

Solution:

  • Ensure Emscripten SDK is installed and activated

  • Source the environment: source /path/to/emsdk/emsdk_env.sh

  • Verify: emcc --version

CI/CD Integration

GitHub Actions Example

name: Build TechKit

on: [push, pull_request]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Install dependencies
        run: |
          sudo apt-get update
          sudo apt-get install -y build-essential cmake
      - name: Build
        run: |
          mkdir build && cd build
          cmake .. -DCMAKE_BUILD_TYPE=Release
          cmake --build . --parallel
      - name: Test
        run: |
          cd build
          ctest --output-on-failure

Next Steps