Skip to content

Getting Started

meta-legend edited this page Jul 4, 2026 · 8 revisions

Getting Started

Pick the path that fits how you build your project. The first option is the simplest; for any other setup, scroll down.

Path Best for Needs
1. Windows prebuilt zip Windows + MSVC, no package manager MSVC, nothing else
2. vcpkg registry Any platform, project already uses vcpkg vcpkg, CMake 3.15+, C++17
3. Build from source + install Linux/macOS, or CMake without the registry CMake 3.15+, C++17, libcurl + nlohmann_json available to CMake
4. Other CMake integrations FetchContent or vendored copy CMake 3.15+

For the Chat LLM features, see Chat requirements at the end.


1. Windows prebuilt zip (easiest)

The fastest way on Windows with MSVC. Download a zip, drop the files into your project, link one .lib. No CMake, no vcpkg, no other dependencies.

  1. From the latest Release, download networkml-<version>-windows-x64.zip. The zip contains:

    • networkml.h (the only header you include)
    • lib/networkml.lib (Release, /MD) and lib/networkmld.lib (Debug, /MDd)
  2. In your project:

    • Add the folder containing networkml.h to your include paths.
    • Add the lib/ folder to your library paths.
    • Link networkml.lib (Release) or networkmld.lib (Debug).

That is the whole setup. Those libraries are self-contained: libcurl and zlib are merged in, and the required Windows system libraries auto-link via #pragma comment(lib, ...) inside the header. You do not link curl or nlohmann_json yourself.

Only works for the matching MSVC toolset and configuration. For Linux/macOS, a different compiler, or projects already using a package manager, use one of the options below.


2. vcpkg registry (recommended for CMake projects)

Network ML is published through its own vcpkg registry, so vcpkg fetches, builds, and installs it for you. There is no manual install step and nothing to put on CMAKE_PREFIX_PATH. Identical setup on Windows, Linux, and macOS, with Debug/Release handled automatically.

  1. Next to your vcpkg.json, add a vcpkg-configuration.json that registers the registry and routes the network-ml package to it:

    {
      "default-registry": {
        "kind": "builtin",
        "baseline": "<your usual vcpkg baseline commit>"
      },
      "registries": [
        {
          "kind": "git",
          "repository": "https://github.com/meta-legend/meta-legend-vcpkg-registry",
          "baseline": "<latest commit of the registry>",
          "packages": [ "network-ml" ]
        }
      ]
    }

    Get the registry baseline with git ls-remote https://github.com/meta-legend/meta-legend-vcpkg-registry HEAD.

  2. Add the dependency to your vcpkg.json:

    { "dependencies": [ "network-ml" ] }
  3. In your CMakeLists.txt - this is the entire CMake change:

    find_package(NetworkML CONFIG REQUIRED)
    target_link_libraries(myapp PRIVATE NetworkML::networkml)

Configure with the vcpkg toolchain (-DCMAKE_TOOLCHAIN_FILE=…/vcpkg.cmake, or a CMake preset) and vcpkg installs Network ML into your project's vcpkg_installed tree on the fly. vcpkg also pulls in libcurl and nlohmann_json as transitive dependencies of the port, and find_package(NetworkML) chains find_dependency for both - you do not name them in your CMakeLists.


3. Build from source + find_package

Clone, build with CMake, install to a prefix, then find_package from your own project. Works without the registry - use this on Linux/macOS with system packages, or when you want to vendor a specific commit.

git clone https://github.com/meta-legend/Network-ML-Library
cd Network-ML-Library

# Configure (if you use vcpkg for the deps, point CMake at its toolchain):
cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE=%VCPKG_ROOT%/scripts/buildsystems/vcpkg.cmake
# On Linux/macOS with system packages (apt/brew), drop the toolchain flag.

# Build + install. On MSVC install both configs so Debug and Release
# consumers each get a matching static library:
cmake --build build --config Release
cmake --install build --config Release --prefix C:/libs/networkml-release
cmake --build build --config Debug
cmake --install build --config Debug   --prefix C:/libs/networkml-debug

In your project's CMakeLists.txt:

find_package(NetworkML CONFIG REQUIRED)
target_link_libraries(myapp PRIVATE NetworkML::networkml)

Point CMake at the matching prefix per configuration with -DCMAKE_PREFIX_PATH=C:/libs/networkml-release (or -debug).

Heads up on dependencies. find_package(NetworkML) automatically chains find_dependency(CURL) and find_dependency(nlohmann_json CONFIG). You do not name them in target_link_libraries, but they still have to be discoverable on the consumer side - via vcpkg, distro packages (apt install libcurl4-openssl-dev nlohmann-json3-dev), Homebrew (brew install nlohmann-json; curl ships with macOS), or any other install.

Visual Studio users can also use File > Open > Folder to open the repository as a CMake project.


4. Other CMake integrations

FetchContent (no install, pulled from GitHub at build time)

include(FetchContent)
FetchContent_Declare(NetworkML
    GIT_REPOSITORY https://github.com/meta-legend/Network-ML-Library.git
    GIT_TAG v2.0.0)
FetchContent_MakeAvailable(NetworkML)

target_link_libraries(myapp PRIVATE NetworkML::networkml)

Pin a release tag for reproducibility. libcurl and nlohmann_json still have to come from your environment (vcpkg toolchain, distro packages, etc.).

add_subdirectory (vendored copy)

If you keep a copy of the library inside your own repository:

add_subdirectory(third_party/Network-ML-Library)
target_link_libraries(myapp PRIVATE NetworkML::networkml)

Same dependency requirement as FetchContent.


Chat (LLM) requirements

For the Chat features:

  • Local model: Ollama running, with a model pulled (e.g. ollama pull llama3.2:1b).
  • Cloud providers (OpenAI, Anthropic, Groq, OpenRouter, DeepSeek): an API key passed to the Chat constructor.

First program

#include <iostream>
#include "networkml.h"
using namespace ML;

int main() {
    Requests req;
    Response r = req.get("https://catfact.ninja/fact");
    std::cout << "status " << r.status << ": " << r.body << "\n";
}

Network ML

Related: File ML (ML::File)

Clone this wiki locally