The following sections describe how to integrate the Tuning Fork library into your toolchain and how to use the functions that the library provides. The library is available as a static or shared library in the AGDK Libraries.

After you've[downloaded the SDK](https://developer.android.com/games/sdk#download)to your machine and checked it into your source control system, make the changes listed in the following sections to your project's build settings.

## Before you begin

You should integrate the[Android Frame Pacing library](https://developer.android.com/games/sdk/frame-pacing)before integrating the Tuning Fork library. If you do this, the Tuning Fork library can automatically record frame time; there is no need to explicitly call the tick functions yourself.

See the following integration guides for more information:

- [Integrate Android Frame Pacing into your OpenGL renderer](https://developer.android.com/games/sdk/frame-pacing/opengl)
- [Integrate Android Frame Pacing into your Vulkan renderer](https://developer.android.com/games/sdk/frame-pacing/vulkan)

## Static library

To link your project to the static library, do the following:

1. Add`gamesdk/include`to your compiler include paths.
2. Add a path of the following form in your linker library paths:

   ```
   gamesdk/libs/architecture_APIapiLevel_NDKndkVersion_stlVersion_Release
   ```

   Look in`gamesdk/libs`and pick the one that best suits your toolchain (for example,`gamesdk/libs/arm64-v8a_API24_NDK17_cpp_static_Release`).
3. Add`-ltuningfork_static`to your linker command (and`-lswappy_static`if you integrated the Android Frame Pacing library).

4. Add the`INTERNET`permission to your`AndroidManifest.xml`file:

       <uses-permission android:name="android.permission.INTERNET" />

## Shared library

The steps in the[static library](https://developer.android.com/games/sdk/performance-tuner/custom-engine/update-build-settings#static-library)section statically link against a version of the Tuning Fork library compiled for the given ABI, API level, NDK, and STL combination. If the combination is not available for your settings, you can instead link against the shared library:

1. Add`gamesdk/include`to your compiler include paths.
2. Add a path of the following form in your linker library paths:

   ```
   gamesdk/libs/architecture_APIapiLevel_NDKndkVersion_stlVersion_Release/lib/tuningfork
   ```
3. Add`-ltuningfork`to your linker command (and`-lswappy`if you integrated the Android Frame Pacing library).

4. Add the`INTERNET`permission to your`AndroidManifest.xml`file:

       <uses-permission android:name="android.permission.INTERNET" />

Static linking gives you a much smaller code footprint as you don't need to bundle the`libtuningfork.so`shared library.

## Using CMake (static library only)

If you are using CMake, see the`gamesdk/samples/tuningfork/insightsdemo/app/CMakeLists.txt`file for an example CMake configuration. It includes a utility file,`gamesdk/samples/gamesdk.cmake`, which performs final checks, adds the proper compiler include paths, and generates a target that you can use to link the library.

To use this utility, do the following:

1. Include this file in your`CMakeLists.txt`file:`include("`<var translate="no">path/to/gamesdk</var>`/samples/gamesdk.cmake")`
2. Call the`add_gamesdk_target`function with the folder containing the gamesdk:`add_gamesdk_target(PACKAGE_DIR
   `<var translate="no">path/to/gamesdk</var>`)`
3. In your`target_link_libraries`for your native library, add`tuningfork`as a dependency (and`swappy`if you integrated the Android Frame Pacing library):` target_link_libraries(native-lib swappy tuningfork ...) `

| **Note:** The path to the gamesdk used for`include`and`add_gamesdk_target`can either be absolute (for example,`/home/yourusername/gamesdk`or`C:\Android\gamesdk`) or relative to the`CMakeLists.txt`file.

For advanced usage of CMake, see the[`gamesdk.cmake`source file](https://android.googlesource.com/platform/frameworks/opt/gamesdk/+/refs/heads/master/samples/gamesdk.cmake).