Panda3D Manual: How to compile a C++ Panda3D program on Mac OS X

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

Mac OS comes with python installed, however because of production cycles your version may be a bit outdated, if you want to download the latest python version, you can go to the Python website. Just make sure that the Panda3D version is compatible with it.

In order to compile you need also to have the GNU G++ compiler. Unlike in Linux, the G++ compiler is not pre-installed in Mac OS X, you will need to install Xcode development tools, the installer comes in the Mac OS installer CDs or DVDs, however for newer versions, you can download it from its website. You will need to register for an account.

Having these two components, we can proceed to compile:

First we must create .o file from our cxx file. We need to link to the Panda3D include files and to the Python include files.

g++ -c filename.cxx -o filename.o -fPIC -O2 -I{pythoninclude} -I{panda3dinclude}

Please change the paths in these commands to the appropiate locations. A list of locations is at the end of the page.

Secondly, we need to generate an executable, you can use the following command:

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

As mentioned above, we need to change the paths accordingly, the paths for Mac OS are listed below:

• {pythoninclude}: The path to your Python include folder. For version 2.5, this is /usr/include/python2.5 by default.

• {panda3dinclude}: Change this to the path to your Panda3D include directory. This would probably look like /Applications/Panda3D/1.6.2/include/ in the case of 1.6.2 but this applies for all versions.

• {panda3dlibs}: Change this to the path to your Panda3D libraries. This is /Applications/Panda3D/1.6.2/lib in the case of 1.6.2 but this applies for all versions.

And lastly to run the created executable, type:

./filename