-
Notifications
You must be signed in to change notification settings - Fork 0
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.
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.
-
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) andlib/networkmld.lib(Debug, /MDd)
-
-
In your project:
- Add the folder containing
networkml.hto your include paths. - Add the
lib/folder to your library paths. - Link
networkml.lib(Release) ornetworkmld.lib(Debug).
- Add the folder containing
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.
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.
-
Next to your
vcpkg.json, add avcpkg-configuration.jsonthat registers the registry and routes thenetwork-mlpackage 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. -
Add the dependency to your
vcpkg.json:{ "dependencies": [ "network-ml" ] } -
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.
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-debugIn 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 chainsfind_dependency(CURL)andfind_dependency(nlohmann_json CONFIG). You do not name them intarget_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.
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.).
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.
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
Chatconstructor.
#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";
}