# Building and Using Jolt Physics ## Build Types Each platform supports multiple build targets - Debug - Debug version of the library, turns on asserts - Release - Release version of the library, no asserts but includes profiling support and can draw the world and simulation properties - ReleaseASAN - As Release but turns on Address Sanitizer (clang only) to find bugs - ReleaseUBSAN - As Release but turns on Undefined Behavior Sanitizer (clang only) to find bugs - ReleaseCoverage - As Release but turns on Coverage reporting (clang only) to find which areas of the code are not executed - Distribution - Shippable version of the library, turns off all debugging support ## Includes The Jolt headers don't include Jolt/Jolt.h. Always include Jolt/Jolt.h before including any other Jolt header. You can use Jolt/Jolt.h in your precompiled header to speed up compilation. ## Defines There are a number of user configurable defines that turn on/off certain features:
General Options (click to see more)
CPU Instruction Sets (click to see more)
## Logging & Asserting To override the default trace and assert mechanism install your own custom handlers in Trace and AssertFailed (see IssueReporting.h). ## Custom Memory Allocator To implement your custom memory allocator override Allocate, Free, AlignedAllocate and AlignedFree (see Memory.h). ## Building
Windows 10+
Linux
Android
macOS
iOS
## Other Build Tools * A vcpkg package is available [here](https://github.com/microsoft/vcpkg/tree/master/ports/joltphysics). * A xmake package is available [here](https://github.com/xmake-io/xmake-repo/tree/dev/packages/j/joltphysics). * Jolt has been verified to build with [ninja](https://ninja-build.org/) through CMake. ## Link Errors If you receive the following error when linking: ``` /usr/bin/ld: libJolt.a: error adding symbols: file format not recognized ``` Then you have not enabled interprocedural optimizations (link time optimizations) for your own application. See the INTERPROCEDURAL_OPTIMIZATION option in CMakeLists.txt. ## Illegal Instruction Error If your CPU doesn't support all of the instructions you'll get an `Illegal instruction` exception. On Linux to see what instructions your CPU supports run `lscpu` and then look at the flags section, on Windows you can use a program like [`coreinfo`](https://learn.microsoft.com/en-us/sysinternals/downloads/coreinfo). Once you know what instructions your cpu supports you can configure the project through cmake and for example disable all special instructions: ``` ./cmake_linux_clang_gcc.sh Release clang++ -DUSE_SSE4_1=OFF -DUSE_SSE4_2=OFF -DUSE_AVX=OFF -DUSE_AVX2=OFF -DUSE_AVX512=OFF -DUSE_LZCNT=OFF -DUSE_TZCNT=OFF -DUSE_F16C=OFF -DUSE_FMADD=OFF ``` Note that this example is for Linux but the cmake settings work on Windows too. ## Doxygen on Windows Documentation can be generated through doxygen: - Install Doxygen (https://www.doxygen.nl/download.html) - Run: run_doxygen.bat