LibMCP 0.6.1
API to control MCPnet
Loading...
Searching...
No Matches
Building LibMCP

After installing all dependencies the next step is to build LibMCP. This is tested on both Linux and Windows.

Clone the GitLab repository.

git clone https://gitlab.mekra-coding.de/mcpnet/libmcp.git
cd libmcp

CMake presets

The presets in CMakePresets.json configure a Ninja build with tests enabled:

Preset Build directory Build type Dependencies
debug build-debug/ Debug installed on the system
release build/ Release installed on the system
windows-debug build-debug/ Debug vcpkg, see Installing Poco C++
windows-release build/ Release vcpkg, see Installing Poco C++

The windows-* presets are only available on Windows.

Configure, build and run the tests in one step:

cmake --workflow --preset release

Or step by step:

cmake --preset release
cmake --build --preset release
ctest --preset release

Executables (examples, tests) and MCP.dll are placed in build/bin/.

Windows

Ninja needs the MSVC environment (cl.exe, INCLUDE, LIB), so run the commands from a "Developer PowerShell for VS" (or "Developer Command Prompt for VS"):

cmake --workflow --preset windows-release

IDEs

Visual Studio, VS Code with the CMake Tools extension and CLion use the presets directly and set up the MSVC environment themselves.

Options

You can also add additional CMake options or project options to the CMake call, e.g. cmake --preset release -DBUILD_PYTHON_BINDINGS=OFF. The defaults are:

-DBUILD_DOCS=OFF
-DBUILD_EXAMPLES=ON
-DMCP_BUILD_SHARED=ON
-DBUILD_PYTHON_BINDINGS=ON

MCP_BUILD_SHARED defaults to BUILD_SHARED_LIBS if that is set. LibMCP does not define BUILD_SHARED_LIBS itself, because as an option() it would switch every other library of a parent project to shared as well.

Install LibMCP to CMAKE_INSTALL_PREFIX:

cmake --install build

Python bindings

To build the Python bindings, install the required development packages before running CMake.

Linux:

sudo apt install python3-dev python3-pybind11
pip install pybind11-stubgen

Windows (Python from python.org):

pip install pybind11 pybind11-stubgen

pybind11-stubgen is optional — without it, no .pyi type stub is generated, but the bindings still build.

To skip the Python bindings entirely, pass -DBUILD_PYTHON_BINDINGS=OFF to the CMake call.

Additional notes

When using a shared LibMCP without installing it globally, MCP.dll / libMCP.so has to be found by every executable that uses LibMCP. On Windows copy it next to the executable, e.g. with $<TARGET_RUNTIME_DLLS:...> or by putting all executables into one folder with CMAKE_RUNTIME_OUTPUT_DIRECTORY.

When building the doxygen documentation you might get some warnings like these:

warning: found subsection command outside of section context!
warning: unable to resolve reference to `docs/pages' for \ref command

This is due to doxygen bugs 5892 and 7032 which were fixed in version 1.8.16 and 1.8.19 respectively. So either you use a newer version of doxygen or access the documentation from GitLab pages.