---
Product: Aspose.Slides
Platform: cpp
Page Type: kb
Canonical URL: https://kb.aspose.org/slides/cpp/how-to-get-started-slides-cpp
Last Updated: 2026-04-04
---

# How to Get Started with Aspose.Slides FOSS for C++

Learn how to add aspose_slides_foss via CMake, create a presentation, add shapes and text, apply fills, and save to PPTX using Presentation, SaveFormat, and ShapeType.

`aspose_slides_foss` for C++ is a free, MIT-licensed library for creating and editing
PowerPoint `.pptx` files — no Microsoft Office required, built with CMake.

## Step-by-Step Guide

### Step 1: Add the Library via CMake

Add `aspose_slides_foss` to your `CMakeLists.txt` (C++20 compiler required):

```cmake
cmake_minimum_required(VERSION 3.20)
project(MyProject)

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)
```

---

### Step 2: Include Required Headers

Include the headers for the classes you need:

```cpp
#include <Aspose/Slides/Foss/presentation.h>
#include <Aspose/Slides/Foss/auto_shape.h>
#include <Aspose/Slides/Foss/shape_type.h>
#include <Aspose/Slides/Foss/text_frame.h>
#include <Aspose/Slides/Foss/export/save_format.h>
```

---

### Step 3: Create a Presentation

Construct a `Presentation` to start with one blank slide, then save it:

```cpp
#include <Aspose/Slides/Foss/presentation.h>
#include <Aspose/Slides/Foss/export/save_format.h>

using namespace Aspose::Slides::Foss;

int main() {
    Presentation prs;
    prs.save("new_presentation.pptx", SaveFormat::PPTX);
    return 0;
}
```

---

### Step 4: Add a Shape with Text

Use `slide.shapes().add_auto_shape()` to insert a rectangle, then call `text_frame()->set_text()`
to add text content:

```cpp
#include <Aspose/Slides/Foss/auto_shape.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 <Aspose/Slides/Foss/export/save_format.h>

using namespace Aspose::Slides::Foss;

int main() {
    Presentation prs;
    auto& slide = prs.slides()[0];
    auto& shape = slide.shapes().add_auto_shape(
        ShapeType::RECTANGLE, 50, 50, 400, 150
    );
    shape.text_frame()->set_text("Hello from Aspose.Slides FOSS!");
    prs.save("with_shape.pptx", SaveFormat::PPTX);
    return 0;
}
```

---

### Step 5: Apply a Fill and Save

Set a solid fill color on the shape before saving:

```cpp
#include <Aspose/Slides/Foss/auto_shape.h>
#include <Aspose/Slides/Foss/fill_format.h>
#include <Aspose/Slides/Foss/fill_type.h>
#include <Aspose/Slides/Foss/presentation.h>
#include <Aspose/Slides/Foss/shape_type.h>
#include <Aspose/Slides/Foss/export/save_format.h>

using namespace Aspose::Slides::Foss;

int main() {
    Presentation prs;
    auto& shape = prs.slides()[0].shapes().add_auto_shape(
        ShapeType::RECTANGLE, 100, 100, 400, 200
    );
    shape.fill_format().set_fill_type(FillType::SOLID);
    shape.fill_format().solid_fill_color().set_color(0xFF, 0x46, 0x82, 0xB4);
    shape.text_frame()->set_text("Styled shape");
    prs.save("styled.pptx", SaveFormat::PPTX);
    return 0;
}
```

## Common Issues and Fixes

**Linker errors with undefined references**
Ensure `target_link_libraries(your_target PRIVATE aspose_slides_foss)` is in your
`CMakeLists.txt` and that the library was fetched successfully via `FetchContent`.

**Header file not found**
Include the full path starting with `<Aspose/Slides/Foss/...>`. Run `cmake --build`
from the build directory, not from the source directory.

**`UnsupportedOperationException` equivalent for unsupported features**
Some features (charts, animations, PDF export) are not supported. Check the project
documentation for the current list of limitations.

**Crash when accessing slides by index**
The default `Presentation` always creates one slide at index 0. If you loaded an empty
file or removed all slides, `prs.slides()[0]` will be out of range.

## Frequently Asked Questions

### Does aspose_slides_foss require Microsoft Office?

No. The library creates and reads `.pptx` files natively in C++ with no dependency
on Microsoft Office, COM automation, or Windows APIs.

### Which compilers and C++ standards are supported?

The library requires C++20 or later. It is tested with GCC 11+, Clang 13+, and MSVC 2022.

### Is the library free for commercial use?

Yes. It is released under the MIT License. You may use, modify, and redistribute it for
any purpose, including commercial applications.

### Can I load an existing PPTX file?

Yes. Pass the file path to the `Presentation` constructor:

```cpp
Presentation prs("existing.pptx");
prs.save("copy.pptx", SaveFormat::PPTX);
```

### How do I add multiple slides?

Use `prs.slides().add_empty_slide(layout)` after obtaining a layout from
`prs.masters()[0].layout_slides()[0]`.

## See Also

- [FAQ — Aspose.Slides FOSS for C++](https://kb.aspose.org/slides/cpp/faq/)
- [How to Create Presentations in C++](https://kb.aspose.org/slides/cpp/how-to-create-presentations-cpp/)
- [How to Add Shapes in C++](https://kb.aspose.org/slides/cpp/how-to-add-shapes-cpp/)
- [Getting Started Docs](https://docs.aspose.org/slides/cpp/getting-started/)
- [API Reference](https://reference.aspose.org/slides/cpp/)
- [Aspose.Slides for C++ — Enterprise Knowledge Base](https://kb.aspose.com/slides/cpp/)