Building with PhysX

Generating projects with CMake

PhysX uses CMake to generate build configuration files (e.g. Microsoft Visual Studio Solutions or Makefiles) for all supported platforms. The PhysX distribution comes with default CMake parameter sets called presets. The build configuration files can be generated with the script generate_projects in the distributions “physx/” directory. This script either prompts for a preset or accepts a preset as a command line parameter. The resulting build configuration files are generated under “physx/compiler/”.

PhysX binaries (including static libraries) are placed into “bin/<platform>.<target>.<compiler>.<runtime>/<configuration>/” directories, for example the vc16win64 checked build puts binaries into “bin/”.

Build Configurations

The SDK has four build configurations available, designed for different stages of development and deployment.

  • the debug build can be useful for error analysis, but contains asserts used for SDK development which some customers may find too intrusive for daily use. Optimizations are turned off for this configuration.

  • the checked build contains code to detect invalid parameters, API race conditions, and other incorrect uses of the API which might otherwise cause mysterious crashes or failures in simulation.

  • the profile build omits the checks, but still has PVD and memory instrumentation.

  • the release build is built for minimal footprint and maximum speed. It omits most checks and instrumentation.

Simulation works the same way in all of them, and all are compiled with high optimization levels (except debug configuration).


We strongly recommend that you use the checked build as the primary configuration for day-to-day development and QA.


PhysX libraries of different build configurations (e.g. the DEBUG version of PhysXVehicle and the CHECKED version of PhysXVisualDebuggerSDK) should never be mixed in an application because this will result a CRT conflict.

Building and linking against PhysX

To build your own PhysX app, your build configuration should be set up such that the PhysX headers and libraries are discoverable at build and link time, respectively.

The following is a minimal example of a CMakeLists.txt project for a user project on Linux that links against all PhysX libraries:

cmake_minimum_required (VERSION 3.1)
project (PhysX_Standalone_Snippet)

option(PHYSX_BUILD_TYPE "The build type of PhysX, i.e., one of {debug, checked, profile, release}" "checked")


    message("Building snippet in debug configuration")
    link_directories("PhysX/bin/linux.clang/debug") # This is the path where PhysX libraries are installed
    message("Building snippet in release configuration with PhysX ${PHYSX_BUILD_TYPE} configuration")
    link_directories("PhysX/bin/linux.clang/${PHYSX_BUILD_TYPE}") # This is the path where PhysX libraries are installed




Within your source (main.cpp in the example above) it is easiest if the provided aggregate include header is used as:

#include "PxPhysicsAPI.h"

This will include the entire PhysX API including core, extensions, vehicles, etc. It is also possible to include subsets of the SDK if preferred, for example:

#include "vehicle/PxVehicleSDK.h"

For examples on how to set up a scene, please refer to the Snippets, e.g., HelloWorld: PhysX Basics.


On the Windows platform, you need to redistribute some of our DLLs to end users as part of your application:

  • PhysXCommon_*.dll - will always be needed.

  • PhysX_*.dll - will always be needed.

  • PhysXFoundation_*.dll - will always be needed.

  • PhysXCooking_*.dll - you only need to bundle if your application cooks geometry data on the fly.

  • PhysXGPU_*.dll - is only needed if your application runs some simulation on the GPU.

Where * is a platform specific suffix, e.g. 32 or 64. You will need one or the other depending on whether your application is built in 64 bit mode.

On Linux builds, everything that needs to be distributed will be in the corresponding install folder that is generated when running make install.

Customize CMake presets

It is possible to customize the CMake presets, which are stored in “physx/buildtools/presets/public/”. Each XML file represents one preset, depending on the platform some CMake switches can be toggled.

General switches:

  • PX_BUILDSNIPPETS - specify whether the PhysX Snippets should be added to the build configuration - default True

Windows switches:

  • PX_GENERATE_STATIC_LIBRARIES - it is possible to switch the PhysX build to output static libs instead of DLLs - default False

  • NV_USE_STATIC_WINCRT - sets static or dynamic runtime usage - default True

  • NV_USE_DEBUG_WINCRT - specify whether debug CRT should be used - default True

  • PX_FLOAT_POINT_PRECISE_MATH - it is possible to switch to precise math rather than fast math, this is beneficial especially for robotics projects, which do require higher precision - default False

Some switches like PX_GENERATE_STATIC_LIBRARIES may result in a need for additional defines to be set within your application. In this case you can include in your application PxConfig.h header, which is generated during generate projects.