Installation

Installation von Aspose.Slides FOSS für C++

Aspose.Slides FOSS for C++ is a header-and-source library built with CMake. It has no binary distribution; you integrate it directly into your CMake project from the GitHub repository. No Microsoft Office or other proprietary runtime is required.


Voraussetzungen

AnforderungDetail
C++-StandardC++20 oder neuer
BuildsystemCMake 3.20 oder neuer
CompilerGCC 10+, Clang 13+ oder MSVC 2019+ (beliebiger Compiler mit C++20-Unterstützung)
BetriebssystemWindows, macOS, Linux
Externe AbhängigkeitenKeine (alle Abhängigkeiten sind vendored oder header-only)

1. CMake FetchContent (Recommended)

Der einfachste Weg, Aspose.Slides FOSS zu Ihrem Projekt hinzuzufügen, ist CMake FetchContent. Fügen Sie dies zu Ihrem CMakeLists.txt:

cmake_minimum_required(VERSION 3.20)
project(my_slides_app LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

include(FetchContent)
FetchContent_Declare(
    aspose_slides_foss
    GIT_REPOSITORY https://github.com/aspose-slides-foss/Aspose.Slides-FOSS-for-Cpp.git
    GIT_TAG        main
)
FetchContent_MakeAvailable(aspose_slides_foss)

add_executable(my_app main.cpp)
target_link_libraries(my_app PRIVATE aspose_slides_foss)

CMake lädt das Repository herunter und stellt das Bibliotheksziel bereit. Kein manuelles Klonen oder systemweite Installation ist erforderlich.

Um eine bestimmte Version für reproduzierbare Builds festzulegen, ersetzen Sie main durch einen Release-Tag oder Commit-Hash:

FetchContent_Declare(
    aspose_slides_foss
    GIT_REPOSITORY https://github.com/aspose-slides-foss/Aspose.Slides-FOSS-for-Cpp.git
    GIT_TAG        v26.3.0
)

2. Git Submodule

Wenn Sie es vorziehen, den Quellcode in Ihrem Repository zu vendorieren:

git submodule add https://github.com/aspose-slides-foss/Aspose.Slides-FOSS-for-Cpp.git third_party/aspose_slides_foss

Verweisen Sie dann von Ihrem CMakeLists.txt:

add_subdirectory(third_party/aspose_slides_foss)
target_link_libraries(my_app PRIVATE aspose_slides_foss)

3. Build and Verify

Nachdem Sie die Abhängigkeit hinzugefügt haben, konfigurieren und bauen Sie Ihr Projekt:

cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build

Erstellen Sie ein minimales main.cpp um den Build zu überprüfen:

#include <Aspose/Slides/Foss/presentation.h>
#include <Aspose/Slides/Foss/export/save_format.h>
#include <Aspose/Slides/Foss/slide.h>
#include <Aspose/Slides/Foss/slide_collection.h>

#include <iostream>

using namespace Aspose::Slides::Foss;

int main() {
    Presentation pres;
    std::cout << "Aspose.Slides FOSS built successfully" << std::endl;
    std::cout << "Slides in empty presentation: " << pres.slides().size() << std::endl;
    return 0;
}

Erwartete Ausgabe:

Aspose.Slides FOSS built successfully
Slides in empty presentation: 1

Schnellstart: Erstellen einer Präsentation mit einer Form

Das folgende Programm erstellt eine neue Präsentation, fügt ein Rechteck mit Text hinzu und speichert sie als .pptx Datei:

#include <Aspose/Slides/Foss/auto_shape.h>
#include <Aspose/Slides/Foss/export/save_format.h>
#include <Aspose/Slides/Foss/presentation.h>
#include <Aspose/Slides/Foss/shape_collection.h>
#include <Aspose/Slides/Foss/shape_type.h>
#include <Aspose/Slides/Foss/slide.h>
#include <Aspose/Slides/Foss/slide_collection.h>
#include <Aspose/Slides/Foss/text_frame.h>

#include <iostream>

using namespace Aspose::Slides::Foss;

int main() {
    Presentation pres;
    auto& slide = pres.slides()[0];

    // Add a rectangle shape and set its text
    auto& shape = slide.shapes().add_auto_shape(ShapeType::RECTANGLE, 50, 50, 400, 150);
    shape.text_frame()->set_text("Hello from Aspose.Slides FOSS!");

    pres.save("hello.pptx", SaveFormat::PPTX);
    std::cout << "Saved hello.pptx" << std::endl;
    return 0;
}

Wichtig: Presentation verwendet RAII. Wenn das Objekt den Gültigkeitsbereich verlässt, werden interne Ressourcen automatisch freigegeben. Sie können auch aufrufen pres.dispose() explizit, falls nötig; das mehrfache Aufrufen ist sicher.


Plattform‑Hinweise

Windows, macOS, Linux: Die Bibliothek wird auf allen Plattformen identisch gebaut. Es gibt keine plattformspezifischen Codepfade oder Binärerweiterungen.

Docker / CI: Klonen oder holen Sie das Repository in Ihrem Build‑Schritt und führen Sie CMake aus. Keine zusätzlichen Systempakete sind erforderlich, außer einem C++20‑Compiler und CMake.

vcpkg / Conan: Derzeit nicht in vcpkg oder Conan veröffentlicht. Verwenden Sie stattdessen FetchContent oder ein Git‑Submodul.


Zusätzliche Ressourcen

 Deutsch