Installation

Installation

This page explains how to add Aspose.PDF FOSS for C++ to an existing CMake project.


Prerequisites

RequirementDetail
C++ compilerC++20 support (clang 16+, gcc 13+, or MSVC 2022 17.5+)
CMake3.22 or later
Python 3Build-time only — a generator step embeds the bundled Standard-14 font outlines into a generated source file
Runtime dependenciesNone — the library links against nothing but the C++ standard library

Step 1 — Add as a CMake subdirectory (recommended)

Vendor or clone the repository into your project tree, then add it as a subdirectory and link the static library target:

add_subdirectory(aspose.pdf-foss-for-cpp)
target_link_libraries(your_app PRIVATE aspose_pdf_foss)

This exposes the library’s public headers and links aspose_pdf_foss into your_app without any package-manager step.


Step 2 — Or build and install standalone

If you prefer a separately built artifact, configure and build out-of-source:

cmake -S . -B build
cmake --build build

The static library lands at build/libaspose_pdf_foss.a (or aspose_pdf_foss.lib on MSVC). For an optimized build, set the build type:

cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build

Link the resulting static library and add the repository’s include/ directory to your project’s include path.


Step 3 — Verify the toolchain

Compile a minimal program against the headers to confirm the toolchain and link step resolve correctly:

#include <aspose/pdf/document.hpp>
#include <iostream>

int main() {
    Aspose::Pdf::Document doc;
    std::cout << "Aspose.PDF FOSS for C++ linked OK — pages: "
              << doc.Pages().Count() << "\n";
}

A successful compile and link, printing pages: 0 for a freshly constructed Document, confirms the installation is working.


Next Steps

See Also