Skip to content

Compiling Sources

Tristan Grespinet edited this page Jul 23, 2019 · 4 revisions

Typical Project structure

└── Project root
    ├── libs
    |   └── fmod
    |       └── {platform}
    |           └── specific platform fmod api goes here
    ├── godot-cpp (gdnative bindings, consider using a git submodule)
    └── fmod-gdnative (this repo, consider using it as a submodule of you GDNatives repo)
        ├── src
        ├── demo
        └── others files/folders

If you look at Sconstruct script, you'll see that it refers to libraries that are in path relatives to parent folder. This is because Utopia-Rise team chose to make this repo integrated to a unique repository, storing all the GDNative for our project.

So, you are supposed to put fmod libraries under libs/fmod/{platform}, according to the platforms you want to support.

Otherwise, you can use our example project, which already contains the appropriate structure.

Feel free to modify SConstruct according to your project structure.

CMakeLists is here for CLion ide, as we are used to JetBrains tools. Unfortunately, CLion does not currently support Sconstruct.

Building the GDNative

Building GDNative API bindings

To Build GDNative bindings you can follow this tutorial from godot official documentation. If you want to regenerate bindings you can add the following argument to your building command :

godotbinpath="path to your godot binary"

For the moment we are focusing on release target. So you may need to add :

target=release

When you're done with that part you should have libgodot-cpp.<platform>.<target>.<bits>.<a|lib> in godot-cpp/bin` folder.

iOS

To build bindings for iOS, we provide our godot-cpp version, with Android and iOS build export. Checkout 3.1-utopia branch. This is also provided with our GDNative example project.
To build on iOS, you should type :

scons platform=ios generate_bindings=True bits=64 target=release

Android

To build bindings for iOS, we provide our godot-cpp version, with Android and iOS build export. Checkout 3.1-utopia branch. This is also provided with our GDNative example project.
First, you should set ANDROID_NDK_ROOT environment variable by typing :

export ANDROID_NDK_ROOT="pathToYourAndroidNDK"

To build on Android, you should type :

scons platform=android generate_bindings=True bits=64 target=release android-abi=arm/arm64

Building the GDNative driver

Download the FMOD Studio API (You need to create an account) and place it in the appropriate platform folder into lib folder (see project structure).

For each platforms, if your project structure is different from the one proposed here, you can overload cpp_bindings and headers parameters.

OSX

To build the GDNative for OSX, you should use this command in fmod-gdnative folder :

scons p=osx target=release

This will generate libGodotFmod.osx.dylib in fmod-gdnative/bin folder.

Be aware that osx is a bit tricky with dynamic library loading. This link explains how to load dynamic dependencies on OSX. By default the GDNative will look for fmod libraries in a libs folder relative to its path when loading the game or the engine. Otherwise, if you want to change that loading path, you can add this parameter fmod-lib-install-path="path to fmod dll".

Linux

To build the GDNative for Linux, you should use this command in fmod-gdnative folder :

scons p=linux use_llvm=yes target=release bits=64

This will generate a libGodotFmod.linux.so in fmod-gdnative/bin folder.

To load fmod dynamic libraries on app or engine loading, fmod GDNative will look in subfolder libs by default, as in OSX part. you can overload this relative path adding this parameter to the command fmod-lib-install-path="path to fmod dll".

Windows

To build the GDNative for Windows, you should use this command in fmod-gdnative folder :

scons p=windows target=release bits=64

This will generate libGodotFmod.windows.dll in fmod-gdnative/bin folder.

To load fmod dynamic libraries on app or engine loading, the simplest way is to put fmod dynamic dependencies in the same folder as GDNative dll.

Android

To build the GDNative for Android, we currently use NDKBuild. So you should use this command in fmod-gdnative folder :

$ANDROID_NDK_ROOT/ndk-build NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=Android.mk  APP_PLATFORM=android-21

This will generate libandroid_fmod_gdnative.so for each supported architectures in libs folder.

To load fmod dynamic libraries on app or engine loading, the simplest way is to put fmod dynamic dependencies in the same folder as GDNative dll, with libc++_shared.so.

iOS

To build the GDNative for iOS, you should use this command in fmod-gdnative folder :

p=ios target=release dynamic=no

This will generate libGodotFmod.ios.a in fmod-gdnative/bin folder.

Those libraries are statics, so you need to add fmod static librairies and godot-cpp static library for ios in your project, with libGodotFmod.ios.a.