Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions content/older.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@ as we update and change OF, you can download older versions of the framework her

--------------------------------

**BETA — 0.12.2-RC1**

Browse all published files and release notes: [0.12.2-RC1](https://github.com/openframeworks/openFrameworks/releases/tag/0.12.2-RC1). This is a prerelease for testing, not the stable release.

--------------------------------

**release v0.12.1**

Browse all platforms: [release v0.12.1](https://github.com/openframeworks/openFrameworks/releases/tag/0.12.1).

--------------------------------

**release v0.12.0**

Browse all platforms: [release v0.12.0][243]
Expand Down
113 changes: 28 additions & 85 deletions content/setup/android-studio.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,109 +4,52 @@
Android Studio
==============

Summary
-------
Install the [latest stable Android Studio](https://developer.android.com/studio) and its Android SDK tools. Use the Project Generator and templates from the same openFrameworks installation. Current development packages are listed on the [nightly release](https://github.com/openframeworks/openFrameworks/releases/tag/nightly); the Android Windows package is listed on the [download page](/download/#android).

Setting up openFrameworks with Android Studio is fairly straightforward. The basic steps are:
## Android NDK 29

- Install Android Studio and the Android SDK
- Install the Android NDK (actually tested version is r15c)
- Download openFrameworks from the download page or from git
- If you got openFrameworks from git:
- Run `scripts/android/download_libs.sh` to download libraries.
- Use the Project Generator to generate Android Studio project files for android examples.
- In Android Studio, use **Open an existing Android Studio project** and select an openFrameworks example from the `examples/android` folder.
- It will ask you for NDK location, either put the path in `local.properties` or click *Project Structure* and select the NDK location.
- Let Android Studio download all other dependencies missing automatically.
- Build and run
Install **NDK r29**, revision **29.0.14206865**, through **Tools → SDK Manager → SDK Tools → Show Package Details → NDK (Side by side)**. See the [official r29 release](https://github.com/android/ndk/releases/tag/r29).

Installation
------------
From the SDK's command-line tools, the equivalent is:

<h3>Install Android Studio and the SDK</h3>

Download and install Android Studio from [https://tools.android.com/download/studio/stable](https://tools.android.com/download/studio/stable) (you need Android Studio 1.0 or higher). It should come with (or automatically install) a recent SDK, though you can customize the SDK version later from within Android Studio using **Tools ➞ Android ➞ SDK Manager**.

In the event that Android Studio does not come with an SDK, you can install it from [https://developer.android.com/sdk/index.html](https://developer.android.com/sdk/index.html) (under "Get the SDK for an existing IDE").

<h3>Install the Android NDK</h3>

This is the C/C++ compiler, headers and libraries for Android. OF 0.10.0 has been tested with the NDK version r15c, newer versions might work but it's not guaranteed.

[https://developer.android.com/ndk/downloads/older_releases](https://developer.android.com/ndk/downloads/older_releases)

- OS X: [https://dl.google.com/android/repository/android-ndk-r15c-darwin-x86_64.zip](https://dl.google.com/android/repository/android-ndk-r15c-darwin-x86_64.zip)
- Linux 64: [https://dl.google.com/android/repository/android-ndk-r15c-linux-x86_64.zip](https://dl.google.com/android/repository/android-ndk-r15c-linux-x86_64.zip)
- Windows 32: [https://dl.google.com/android/repository/android-ndk-r15c-windows-x86.zip](https://dl.google.com/android/repository/android-ndk-r15c-windows-x86.zip)
- Windows 64: [https://dl.google.com/android/repository/android-ndk-r15c-windows-x86_64.zip](https://dl.google.com/android/repository/android-ndk-r15c-windows-x86_64.zip)


Once you downloaded the android ndk .zip, you'll have to install it in the "ndk" folder of android studio sdk.
To know the path of the android studio sdk, open android studio. You should see the welcome screen. If you have an open project close it with "File" > "Close project". Click on the button at the bottom right : "Configure" > "SDK manager". Can also be found in "File" > "Settings" > "File
At the top you should have a path pointing to the SDK location, called "Android SDK location".
On windows it is probably :
`C:\Users\%userprofile%\AppData\Local\Android\sdk\`

Now in the file explorer go to that location, and look for a "ndk" folder. If it doesn't exist create one, and paste the extracted `android-ndk-r15c` folder here...


<h3>Download openFrameworks</h3>

[Download](/download) it from the downloads page.
Once downloaded, extract it in the location of your choice.


<h3>Open the project</h3>

At the Android Studio welcome screen select **Open an Existing Android Studio Project**.
```sh
sdkmanager "ndk;29.0.14206865" "cmake;3.22.1"
```

![](open-existing-project.png)
Install the Android platform SDK and Build Tools requested by your project's Gradle files as well. Current source declares compile/target SDK 34, minimum API 25 and Build Tools 37.0.0. Use the supplied Gradle wrapper and Android Studio's compatible JDK.

Then browse to any of the android examples in `examples/android`.
The current master templates pin **NDK 30**. To use NDK 29 with that tree, explicitly set `ndkVersion '29.0.14206865'` in both the generated app's `ofApp/build.gradle` and `libs/openFrameworksCompiled/project/android/openframeworksAndroid/build.gradle`. Use third-party libraries built for the same NDK and rebuild the native core; do not mix stale output from another NDK. For a core build through the helper script, pass the matching revision:

![Opening androidEmptyExample](androidEmptyExample.png)
```sh
NDK=29.0.14206865 libs/openFrameworksCompiled/project/android/cmake.sh
```

Accept all the prompts and wait for Android Studio to set up the project.
The helper also needs the SDK location (`ANDROID_HOME` on Linux/macOS) and the SDK's CMake/Ninja installation. These NDK 29 override steps do not change the source tree's upstream default.

You'll have to wait a bit: the first sync will automatically build openFrameworks. If it doesn't work (Gradle sync still fails), try looking at the Troubleshooting tips bellow. In some cases, clicking on the error in the console window will take you to a solution, such as installing various versions of the Android SDK. In some cases, you may have to do this several times to solve several missing dependencies.
## Create or update a project

<h3>Build and run</h3>
1. Open the Project Generator supplied with the selected openFrameworks tree.
2. In **Settings**, set **OF path** to the root containing `addons`, `apps`, `libs` and `scripts`.
3. Enable **Advanced options** and choose **Android (Android Studio)**. Set the project name and parent directory, choose addons, then generate.
4. Open the generated project directory in Android Studio and let Gradle synchronize. Install any SDK components requested by the project.
5. Choose an emulator or connected device, enable USB debugging when using a device, then click **Run**.

Press the Play button next to the `androidEmptyExample` shown in the toolbar. With any luck, it should build the app, and momentarily deploy it to your Android device (or prompt you to deploy it on a suitable emulator). If the app runs, congratulations! You have setup openFrameworks.
From a source checkout, download Android libraries with `scripts/android/download_libs.sh` first. Linux users can build the command-line generator with `scripts/linux/compilePG.sh`. See the [Project Generator guide](/learning/01_basics/create_a_new_project/).

To deploy on your android device you may have to download the appropriate SDK (deppending on your android version). Your device have to be in "Develloper mode", with Usb debug activated.
## CMake and Gradle {#cmake-and-gradle}

Creating new projects
--------------------
Android uses its dedicated CMake integration through Gradle, not the generic desktop **cmake** template. The generated app's native `CMakeLists.txt` is under `ofApp/src/`; the core's CMake project is under `libs/openFrameworksCompiled/project/android/openframeworksAndroid`.

To create new projects just use the project generator for your platform that you can find in the root folder. For linux you'll need to run
Build the generated project with Android Studio, or from its root:

```sh
scripts/android/compileLinuxPG.sh
./gradlew assembleDebug
```

This builds the command-line generator, not the Electron GUI. Follow [Create a new project](/learning/01_basics/create_a_new_project/) for the generator workflow, and select **Android (Android Studio)** when using the GUI supplied with your download.

Troubleshooting
--------------

- If you have an error like this : `Caused by: org.gradle.api.GradleException: You havent set the path to the NDK library. Please set the property 'ndk.dir' in C:\Users\%userprofile%\%path_to_of%\examples\android\%example_name%\local.properties to the root of the NDK library, or go to Project Structure and select the folder.`
- Click on the link provided by the error, it should open a file.
- in that file there is probably something a line like `sdk.dir=C\:\\Users\\%username%\\AppData\\Local\\Android\\Sdk` (Windows)
- dupplicate this line and change "sdk.dir" in "ndk.dir", and add "\\ndk\\android-ndk-15" at the end. You should have something like that : `ndk.dir=C\:\\Users\\%username%\\AppData\\Local\\Android\\Sdk\\ndk\\android-ndk-r15c`
- Save the file, close the project and try to open the project again
(You may have to do this for every example, but once you done it with the "empty android example" it should be fine)

- If the error is asking to, install `Android SDK build tools`. In android studio, no project opened, go to "Configure" > "SDK manager" > "SDK Tools". Check the `Show package details` at the bottom. Install version 25.0.3 of `Android SDK build tools`.

- You may need to adjust the following numbers to match your installed Android Studio and Android SDK. Android Studio should offer to fix these values for you when you open the appropriate build files.

- The Gradle version specified in `/build.gradle`
- The `compileSdkVersion`, `buildToolsVersion`, `minSdkVersion`, `targetSdkVersion` values
in `/addons/ofxAndroid/ofAndroidLib/build.gradle` and `/apps/myApps/androidEmptyExample/build.gradle`
On Windows use `gradlew.bat assembleDebug`. Follow Gradle's generated module/flavor tasks to install or run the app. See the [CMake guide's Android section](/setup/cmake/#android).

- If you get strange linker errors, check that you are using the 15c version of the NDK. Newer NDKs might work but usually there's some always some fixes that need to be done when moving to a new NDK version.
## Troubleshooting

- If you get make errors on gradle sync without any details, run `chmod +x gradlew; ./gradlew` from within the project folder to build the project from command line, and get more detailed error messages.
Check that `sdk.dir` in the project's `local.properties` points to the installed SDK. Prefer side-by-side `ndkVersion` selection over old `ndk.dir` instructions. If synchronization fails, read the Gradle error for the exact missing SDK, Build Tools, NDK or CMake version; use the versions declared by that project rather than upgrading them independently.

- If, when syncronizing a project for the first time, clicking on the console messages does not solves the problem regarding a missing dependency of the android API (like for example Android API 25), open the sdk from the console, select the missing API and install it
The current generator/template combination can fail creating a new Android project with template-copy errors involving `bin`, `srcJava` or `ofApp/src/res`. Until that is resolved, start from an already-generated Android example in the matching published package. This is a project-generation issue, separate from NDK selection; changing back to the old r15c instructions will not fix it.
119 changes: 119 additions & 0 deletions content/setup/cmake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
## -*- coding: utf-8 -*-
.. title: CMake

CMake setup
===========

Use a current [nightly openFrameworks package](https://github.com/openframeworks/openFrameworks/releases/tag/nightly) or a source checkout containing `libs/openFrameworksCompiled/project/CMake` and `scripts/templates/cmake`. These instructions cover the CMake support being prepared for 0.12.2; the 0.12.1 stable packages use their existing IDE projects and makefiles.

## Requirements

Install the compiler, system dependencies and openFrameworks libraries described in your platform's setup guide before configuring CMake. CMake generates build files; it does not install these dependencies.

- CMake 3.22 or newer for desktop and Emscripten builds.
- CMake 3.28 or newer for iOS and tvOS, to link xcframeworks directly.
- CMake 4.2 or newer for the [Visual Studio 18 2026 generator](https://cmake.org/cmake/help/v4.2/generator/Visual%20Studio%2018%202026.html).
- Ninja, Make, Xcode or Visual Studio, depending on the selected generator.

## Generate a CMake project

In the current Project Generator, enable **Advanced options**, select the platform matching your libraries, and choose the **cmake** template. Generate or update the project. CMake is a template added to the selected platform, not a separate platform.

For example, from the openFrameworks root with the command-line generator on your PATH:

```sh
projectGenerator -o"$PWD" -plinux64 -tcmake apps/myApps/mySketch
```

Replace `-plinux64` with `-posx`, `-pvs`, `-pmsys2`, `-pemscripten`, `-pios` or `-ptvos` as appropriate. Use the generator supplied with the same openFrameworks tree. See the [Project Generator guide](/learning/01_basics/create_a_new_project/#cmake-projects).

For a project that already has `src/`, you can instead copy `scripts/templates/cmake/CMakeLists.txt` into the project folder. The template assumes `apps/myApps/<project>`; pass `-DOF_ROOT=/absolute/path/to/openFrameworks` when configuring a project elsewhere.

The CMake template reads sources from `src/` and addons from `addons.make`. It preserves an existing `CMakeLists.txt` when PG updates a project. Review custom CMake files when changing openFrameworks versions.

## Build a project

From the folder containing your project's `CMakeLists.txt`:

```sh
cmake -S . -B build-cmake -DCMAKE_BUILD_TYPE=Release
cmake --build build-cmake --parallel
```

The app is placed in the project's `bin/` folder. CMake reuses a matching compiled core when available and builds it otherwise. Add `-DOF_BUILD_CORE=ON` when you need to rebuild the core after changing its sources.

Use a separate build directory when changing platform, generator, architecture or toolchain. Ninja and Make use `CMAKE_BUILD_TYPE`; Xcode and Visual Studio use `--config Release` or `--config Debug` on the build command instead.

## macOS

```sh
cmake -S . -B build-xcode -G Xcode
cmake --build build-xcode --config Release
```

Open the generated `.xcodeproj` in `build-xcode`, or run the app from `bin/`. Ninja also works with `-G Ninja -DCMAKE_BUILD_TYPE=Release`. See [Xcode setup](/setup/xcode/).

## Linux and Raspberry Pi

```sh
cmake -S . -B build-cmake -G Ninja -DCMAKE_BUILD_TYPE=Release
cmake --build build-cmake --parallel 2
```

On a native build, CMake detects x86_64, aarch64, armv7l or armv6l from the compiler/toolchain. The libraries must match that target. Selecting a platform alone does not make a cross-compiler; cross-builds also need a toolchain and target system dependencies. See [Linux](/setup/linux-install/) and [Raspberry Pi](/setup/raspberrypi/).

## Windows: Visual Studio

From a terminal with the matching Visual Studio C++ tools installed:

```sh
cmake -S . -B build-vs2026 -G "Visual Studio 18 2026" -A x64
cmake --build build-vs2026 --config Release
```

For Visual Studio 2022 use `-G "Visual Studio 17 2022"` and a new build directory. Use `-A ARM64` or `-A ARM64EC` with the combined x64/ARM64/ARM64EC library package. The VS 2019 package is x64-only; follow the [Visual Studio guide](/setup/vs/) for its native projects.

## Windows: MSYS2

Open the UCRT64, CLANG64 or CLANGARM64 shell matching your openFrameworks download, then install its CMake and Ninja packages:

```sh
pacman -S --needed "${MINGW_PACKAGE_PREFIX}-cmake" "${MINGW_PACKAGE_PREFIX}-ninja"
cmake -S . -B build-cmake -G Ninja -DCMAKE_BUILD_TYPE=Release
cmake --build build-cmake --parallel
```

Keep the compiler, libraries and runtime DLLs in the same MSYS2 environment. See [MSYS2 setup](/setup/msys2/).

## Emscripten

Activate the SDK and download the matching libraries first. Current openFrameworks source pins Emscripten **7.0.0**.

```sh
emcmake cmake -S . -B build-web -G Ninja -DCMAKE_BUILD_TYPE=Release
cmake --build build-web --parallel
emrun bin/em/mySketch/
```

Replace `mySketch` with your project name. WebGL 2 is the default; configure with `-DOF_WEBGL_VERSION=1` for WebGL 1. See [Emscripten setup](/setup/emscripten/).

## Apple mobile platforms {#apple-mobile-platforms}

On macOS, with Xcode and CMake 3.28 or newer, configure an iOS simulator build:

```sh
cmake -S . -B build-ios-sim -G Xcode -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphonesimulator
cmake --build build-ios-sim --config Release
```

For tvOS use a separate directory, `-DCMAKE_SYSTEM_NAME=tvOS` and `-DCMAKE_OSX_SYSROOT=appletvsimulator`. For a physical device use `iphoneos` or `appletvos` and add `-DOF_APPLE_DEVELOPMENT_TEAM=YOUR_TEAM_ID`. The minimum targets are iOS 15 and tvOS 18. See [iOS / tvOS setup](/setup/iphone/).

Mac Catalyst (also called catOS in library-build scripts) is not a standalone platform in this generic CMake entry point. Do not configure it with an invented `OF_PLATFORM=catos`; use the appropriate Apple source project and toolchain.

## Android

Android uses its own Gradle/CMake integration under `libs/openFrameworksCompiled/project/android`, rather than the generic desktop `cmake` template. Generate an **Android** project and build it with Android Studio or its Gradle wrapper. See [Android Studio and CMake](/setup/android-studio/#cmake-and-gradle).

## Further reference

The [CMake README in openFrameworks](https://github.com/openframeworks/openFrameworks/blob/master/libs/openFrameworksCompiled/project/CMake/README.md) lists core-only builds, addons, tests, examples and build options.
Loading
Loading