Skip to content

Building From Source

Ayush Thakur edited this page Dec 11, 2025 · 1 revision

This page provides a developer-friendly introduction to building and running the MTConnect C++ Agent. It covers the essential setup steps, explains what each step does, and outlines platform-specific installation instructions.

Quick Start

The Quick Start section gives you the fastest possible path to running a working MTConnect Agent instance. It assumes no prior knowledge of MTConnect, Conan, or the agent architecture.

1. Clone the Repository

Clone the official MTConnect C++ Agent repository and navigate into it:

git clone https://github.com/mtconnect/cppagent.git
cd cppagent

2. Build Using Conan

The agent uses Conan to automatically download and configure dependencies such as Boost, libxml2, and libcurl. This keeps builds consistent across platforms. Run:

conan create . --build=missing

This command will:

  • resolve all required third-party libraries,
  • compile the agent and its components,
  • bundle everything into a runnable package.

If this is your first time using Conan, it may take several minutes to download packages.

3. Create a Minimal Configuration File

Create a file named agent.cfg in the project root directory. Example:

Devices = Devices.xml
Port = 5000

Adapters {
  MyCNC {
    Host = localhost
    Port = 7878
  }
}

What this configuration means:

  • Devices – Points to the Device XML file that describes the machine’s structure and DataItems.
  • Port – Defines the HTTP port where the agent will serve MTConnect responses.
  • Adapters – Lists one or more SHDR inputs that provide real-time machine data to the agent.

If you don’t already have a Device XML file, you can use one from the /samples directory.

4. Run the Agent

To start the agent using your configuration file:

./agent run agent.cfg

If the configuration is valid, the agent will:

  • load the Device XML
  • initialize the internal data buffer
  • connect to the adapter
  • start listening for HTTP requests
  • begin serving MTConnect XML/JSON

5. Verify the Agent Is Running

You can verify the agent from any browser, cURL, or REST client.

Test Endpoints

Endpoint Description
/probe Shows device metadata and structural information
/current Returns the latest value of every DataItem
/sample Returns time-series sample data

Example:

curl http://localhost:5000/probe

You should see a valid MTConnect XML document.

Installation

This section covers detailed installation and build steps for Linux, Windows, and macOS. Because the agent uses CMake + Conan, the process is consistent, but dependencies vary by platform.

Linux Build

Install Required Packages

Use your system package manager to install C/C++ build tools:

sudo apt-get install build-essential cmake libssl-dev libcurl4-openssl-dev

Build the Agent

From the repository root:

conan install . --build=missing
cmake --preset conan-release
cmake --build build-release

This will produce an agent executable in the build folder.

Windows Build

Windows is widely used in machine-shop environments, especially when connecting directly to CNC controllers or industrial PCs.

Requirements

  • Visual Studio 2022 with the Desktop C++ workload
  • CMake
  • Conan (Python-based package manager)

Build Instructions

conan install . --build=missing
cmake --preset conan-release
cmake --build build-release --config Release

This will produce agent.exe.

macOS Build

macOS is ideal for development, training, and testing because it provides a Unix environment with simpler toolchains.

Install Dependencies

brew install cmake openssl conan

Build the Agent

conan install . --build=missing
cmake --preset conan-release
cmake --build build-release

Clone this wiki locally