How to compile a C++ Panda3D program on LinuxΒΆ

This short guide explains how to build a Panda3D game written in C++ game under Linux.

First of all, you should install a suitable compiler. We recommend either the LLVM Clang compiler or the GNU G++ compiler. These are usually provided by the Linux distribution (on Ubuntu, they can be installed via the build-essential package).

Now, we need to create a .o file from our cxx file. We need to specify the location of the Panda3D include files. Please change the paths in these commands to the appropiate locations.

g++ -c filename.cxx -o filename.o -std=gnu++11 -O2 -I{panda3dinclude}

To generate an executable, you can use the following command:

g++ filename.o -o filename -L{panda3dlibs} -lp3framework -lpanda -lpandafx -lpandaexpress -lp3dtoolconfig -lp3dtool -lp3direct

Note: In these two commands, you need to change a few paths:

  • {panda3dinclude}: Change this to the path to your Panda3D include directory. This would probably look like /usr/include/panda3d/.

  • {panda3dlibs}: Change this to the path to your Panda3D libraries. Usually this is just /usr/lib/panda3d or sometimes /usr/lib.

Here is an equivalent SConstruct file, organized for clarity:

pyInc = '/usr/include/python3.7m'
pandaInc = '/usr/include/panda3d'
pandaLib = '/usr/lib/panda3d'

    CCFLAGS=['-fPIC', '-O2', '-std=gnu++11'],
    CPPPATH=[pyInc, pandaInc],

To run your newly created executable, type:


If it runs, congratulations! You have successfully compiled your own Panda3D program!