# Installing

The SDK comes as one download per platform or engine, made for your app id. Each holds the library, its headers or
package, and your `sona-licence.json`.

## The download

1. Ask for an app id, with the request form or `POST /sona/v1/requests` ([requests](web-api.md#access)). The
   request gives a contact address and accepts the Developer Terms. An app that only reads is approved at once, and
   the answer carries the app id and its key (`sak_...`), shown once.
2. Accept the SDK Licence once for the app, on [your app's page](https://360sona.com/devapp.html#sdk) or with the API.
3. Download with `?platform=`:

```bash
curl -X POST https://360sona.com/sona/v1/apps/YOUR_APP_ID/sdk-licence \
  -H "Authorization: Bearer sak_..." \
  -H "Content-Type: application/json" -d '{ "agree": "I have read and understand the SDK Licence" }'
curl -OJ -H "Authorization: Bearer sak_..." \
  "https://360sona.com/sona/v1/apps/YOUR_APP_ID/sdk?platform=linux-x64"
```

| `platform` | For | Library |
|---|---|---|
| `web` (the default) | Pages and web apps | `sona-renderer.js` |
| `windows-x64` | C, C++, C#, Rust, Python on Windows | `bin/sona.dll`, `lib/sona.lib` |
| `linux-x64` | The same on Linux and Steam Deck | `lib/libsona.so`, `lib/libsona.a` |
| `linux-arm64` | C, C++, Rust, Python on 64-bit ARM Linux | `lib/libsona.so` |
| `macos` | C, C++, C#, Rust, Python on macOS 11 or later, Apple silicon and Intel | `lib/libsona.dylib` (universal) |
| `ios` | C and C++ on iOS 13 or later | `lib/sona.xcframework` |
| `android` | C and C++ on Android | `lib/arm64-v8a/libsona.so`, `lib/x86_64/libsona.so` |
| `unity` | Unity 2021.3 or later | the package `com.360sona.renderer`, its Plugins for Windows, Linux, macOS, Android and iOS |
| `godot` | Godot 4.7 or later | `addons/sona` with `sona.gdextension`, for Windows, Linux (x64, arm64), macOS and Android |
| `unreal` | Unreal Engine 5.8 or later | the plugin `Sona360`, for Win64, Linux, Mac, Android and iOS |
| `wasm` | The core in WebAssembly, data only | `sona-core.wasm`, `sona-core.mjs` |
| `xbox360` | Xbox 360 homebrew: `.xex` titles on xsdk, and libxenon | `lib/libsona.a` (xsdk, with HTTPS), the starter and other titles in `samples/x360`, `lib/xenon/libsona-xenon.a` ([Xbox 360 homebrew](guides/xbox360.md)) |

Each library is stamped for your app and build, so use your own download and do not pass it on. On macOS and iOS
the stamped library is signed again for your app as it downloads; until the SDK is signed with an Apple Developer ID,
macOS asks once, in Privacy & Security, before it loads ([platforms](platforms.md#macos-and-ios)).

## What is in a native download

| Path | What it is |
|---|---|
| `include/` | `sona.h` and the optional modules' headers |
| `lib/`, `bin/` | The library for that platform; on Windows and Linux, the optional modules' libraries beside it |
| `bindings/` | The C++ header (`sona.hpp`) and the C#, Rust and Python packages' sources, where the platform has them |
| `samples/c/` | Small programs, one per feature |
| `data/sona-catalogue.bin` | The [offline catalogue](#the-offline-catalogue), only when the download is asked for with `&catalogue=1` |
| `bench/` | `sona-bench`, the program every number in these docs comes from |
| `sona-licence.json` | Your licence: pass its bytes to `sona_open` |
| `README.md`, `LICENSE.txt`, `THIRD-PARTY.txt` | The licence text and the notices to keep with what you ship |

## The offline catalogue

Item names, search, random avatars and the player editor read the offline catalogue, one data file. Tick
**Offline catalogue** on your app's page when you download, or add `&catalogue=1`:

```bash
curl -OJ "https://360sona.com/sona/v1/apps/YOUR_APP_ID/sdk?platform=linux-x64&catalogue=1" -H "Authorization: Bearer sak_..."
```

It is `data/sona-catalogue.bin` in the download. The tutorials' commands name it `sona-catalogue.bin` beside the
program, so copy it there or give its path (`--catalogue sdk/data/sona-catalogue.bin`); the `sona` tool finds it by
itself with `--sdk sdk`. Use the catalogue from the same download as the library
([the catalogue](guides/catalogue.md)).

## Optional modules

The player editor, face tracking, body tracking, the NPC kit and XR are libraries of their own beside the core:
`sona_editor`, `sona_track`, `sona_body`, `sona_npc` and `sona_xr`, each with its header in `include/`
(`sona_editor.h` and so on). The Linux x64 download has them in `lib/` (`libsona_editor.so` and so on), the Windows
download in `bin/` with their import libraries in `lib/`. Link the ones you use together with the core:

```text
cc -std=c99 -I sdk/include my_vtuber.c -L sdk/lib -lsona_track -lsona \
  -Wl,-rpath,sdk/lib -o my_vtuber
```

The other platforms' downloads hold the core alone, except that the Godot and Unreal downloads carry the editor
module their plugin uses.

## Starters and templates

The plaza starter for every platform but C++ (the `sona` tool makes that project), the plaza demo, the lobby,
VTuber, bot and VR templates and the NPC kit's program are one archive of source files,
[360sona-templates.tar.gz](360sona-templates.tar.gz). It is the same for every app and platform. Where its link
reads "ask for it", it is sent on request: send a request of kind `other` that names your app id
([requests](web-api.md#access)).

Unpack it into the folder of your download:

```sh
tar xzf 360sona-templates.tar.gz -C sdk
```

`starters/` and `templates/` then sit beside `include/`, `lib/` and `bindings/`, which is where their build
commands expect them. [The plaza starter](tutorials/starter-plaza.md) is the one to begin with;
[templates](guides/templates.md) lists the rest.

### The sample avatars

The archive holds three lists of avatars, each a JSON array of `{ "title", "b64" }` (a name and a base64 manifest):

| File | Avatars | Read by |
|---|---|---|
| `devs-cast.json` | 60 sample avatars | The guides' commands: `--cast devs-cast.json --member <n>` picks one |
| `starters/showcase-cast.json` | 55 costumes | The C, C#, Rust and Python starters, which walk twelve of them by index (`--cast`) |
| `starters/web/plaza-cast.json` | The same twelve costumes alone | The web, Android and iOS starters, and the Unreal starter as `Content/Sona360/plaza-cast.json` |

Any list in that form works: put your own avatars in one to see them instead. `devs-cast.json` is also a file of
these docs, [devs-cast.json](devs-cast.json), for a folder without the archive:

```sh
curl -O https://360sona.com/devs/docs/devs-cast.json
```

### Other files the templates use

The templates link nothing that is not in the download or the system, except these, which you fetch once:

| File | Used by | Where it comes from |
|---|---|---|
| `stb_truetype.h` | The plaza demo, the bot template | One header of the stb libraries (public domain): [github.com/nothings/stb](https://github.com/nothings/stb) |
| `DejaVuSans.ttf`, `DejaVuSansMono.ttf` | The plaza demo (Linux), the bot template | The DejaVu fonts (free licence): `fonts-dejavu-core` on Debian and Ubuntu, `ttf-dejavu` on Arch, or [dejavu-fonts.github.io](https://dejavu-fonts.github.io) |
| SDL3 | The plaza demo; the windows of the lobby and the VTuber kit | [libsdl.org](https://libsdl.org), or the system's package (`libsdl3-dev`, `sdl3`) |
| `face_landmarker.task` | The VTuber kit, face tracking | MediaPipe's face landmarker model, below |
| The OpenXR loader, Vulkan | The VR template | The [OpenXR SDK](https://github.com/KhronosGroup/OpenXR-SDK) and the [Vulkan SDK](https://vulkan.lunarg.com) |

```sh
curl -LO https://storage.googleapis.com/mediapipe-models/face_landmarker/face_landmarker/float16/1/face_landmarker.task
pip install mediapipe numpy
```

## Your language

The code goes in your project; the library is always the one from your download. [Packages](guides/packages.md) has
every channel.

### C

Add `include/` to the include path and link the library. Keep the shared library where the loader finds it.

```bash
cc -std=c99 -I sdk/include hello.c -L sdk/lib -lsona \
  -Wl,-rpath,sdk/lib -o hello
```

On Windows, in a Developer PowerShell for Visual Studio, link the import library and keep `sona.dll` next to the
program:

```powershell
cl /I sdk\include hello.c sdk\lib\sona.lib
copy sdk\bin\sona.dll .
```

The [C tutorial](tutorials/c.md) builds this program.

### C++

`bindings/cpp/sona.hpp` is a header-only wrapper over the C library: add its folder to the include path too.

```bash
c++ -std=c++11 -I sdk/include -I sdk/bindings/cpp hello.cpp \
  -L sdk/lib -lsona -Wl,-rpath,sdk/lib -o hello_cpp
```

The [C++ tutorial](tutorials/cpp.md) builds this program.

### C#

```bash
dotnet add package Sona360
```

Keep the library beside the program, or on the loader path. The same package is in the download as source: with no
network, or before the package is on NuGet, reference it instead:

```sh
dotnet add reference sdk/bindings/csharp/Sona.csproj
```

The [C# tutorial](tutorials/csharp.md) builds a program against it.

### Rust

```bash
cargo add sona360
```

In code it is `use sona;`. Set `SONA_LIB_DIR` to the folder that holds the library when you build (`sdk/lib`;
on Windows, the folder of `sona.lib`); at run time the loader finds it on its path (`sona.dll` on the `PATH` on
Windows). The crate is in the download as source too, for use with no network or before it is on crates.io:

```sh
cargo add --path sdk/bindings/rust/sona
```

The [Rust tutorial](tutorials/rust.md) builds a program against it.

### Python

```bash
pip install sona360
```

The package loads the library from `SONA_LIB_DIR`, or from beside the package. It is in the download as source too:
with no network, or before it is on PyPI, put its folder on the module path instead (on Windows,
`$env:PYTHONPATH = "$PWD\sdk\bindings\python"`):

```sh
export PYTHONPATH="$PWD/sdk/bindings/python"
```

The [Python tutorial](tutorials/python.md) runs a program against it.

### JavaScript

The web download is a zip with `sona-renderer.js`, its types and examples. Register the origins your pages run on
first ([getting it](web-api.md#sdk-download)). For three.js, Babylon.js and React:

```bash
npm install @360sona/three
```

The [web tutorial](tutorials/web.md) draws a first avatar.

### Unity

In the Package Manager, Add package from disk, and pick the package's `package.json` (or add the git URL). Put
`sona-licence.json` on a `SonaContext` and add a `SonaAvatar`. The [Unity tutorial](tutorials/unity.md) goes on
from here.

### Godot

Copy `addons/sona` into the project and enable the plugin (Godot 4.7 or later). Put `sona-licence.json` at
`res://sona-licence.json` and add a `SonaAvatar3D`. The [Godot tutorial](tutorials/godot.md) goes on from here.

### Unreal

Copy `Sona360` into the project's `Plugins` folder and build. Put `sona-licence.json` at
`Content/Sona360/sona-licence.json`, then add a `USonaAvatarComponent` or the Load 360sona Avatar node. The
[Unreal tutorial](tutorials/unreal.md) goes on from here.

## Avatar files

The library draws avatars from item files it reads at run time. Give `sona_open` one or more sources, asked in order:

| Source | `kind` | Use it when |
|---|---|---|
| The 360sona gate | `SONA_SOURCE_GATE` | You want items streamed over https for your app id, with nothing to install |
| A folder | `SONA_SOURCE_DIR` | You keep the item files yourself, in a folder laid out as the gate serves them |
| A console's storage | `SONA_SOURCE_CONSOLE` | The program runs on an Xbox 360, or reads a console's Content tree |
| Your own reader | `SONA_SOURCE_CUSTOM` | The files are in your own archive or network layer |

## The tools

The command line (`sona`), the MCP server (`sona-mcp`) and SDK Studio install apart from the SDK, with one installer
per system: [installing the tools](guides/installer.md).

## Check it

```c
printf("sona %s on %s\n", sona_version(), sona_platform());
```

```cpp
std::printf("sona %s on %s\n", sona::version(), sona::platform());
```

```csharp
Console.WriteLine($"sona {SonaLibrary.Version} on {SonaLibrary.Platform}");
```

```rust
println!("sona {} on {}", version(), platform());
```

```python
print("sona", sona.version(), "on", sona.platform())
```

If `sona_open` fails, `sona_last_error` gives the message and the fix; [troubleshooting](troubleshooting.md) lists every
code.
