View on GitHub

Cardinal3D

Stanford CS248A (Assignments 2 and 3)

Building Cardinal3D

To create a private git mirror that can pull changes from Cardinal3D, see Git Setup (optional, you can just simply clone the repo).

Note: the first build on any platform will be very slow, as it must compile most dependencies. Subsequent builds will only need to re-compile your edited Cardinal3D code.

Linux

The following packages (ubuntu/debian) are required, as well as CMake and either gcc or clang:

sudo apt install pkg-config libgtk-3-dev libsdl2-dev

The version of CMake packaged with apt may be too old (we are using the latest version). If this is the case, you can install the latest version through pip:

pip install cmake
export PATH=$PATH:/usr/local/bin

Finally, to build the project:

mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo .. 
make -j4

The same process should also work modified for your distro/package manager of choice. Note that if you are using Wayland, you may need to set the environment variable SDL_VIDEODRIVER=wayland when running Cardinal3D for acceptable performance.

Notes:

Windows

The windows build is easiest to set up using the Visual Studio compiler (for now). To get the compiler, download and install the Visual Studio Community 2022 here. Be sure to install the “Desktop development with C++” component. You can download CMake for windows here.

Once you have VS and CMake installed, you can follow the same procedure as PA1 (first run CMake to create Cardinal3D.sln, then open it in VS) to build, run and debug the project. The default build mode is RelWithDebInfo, you can also build in Debug mode, which, while far slower, makes the debugging experience much more intuitive.

Make sure that you have “Treat Warnings As Errors” set off in the project properties in Visual Studio. You can do this by right clicking on the project in the solution explorer, selecting “Properties”, and then navigating to “C/C++” -> “General” and setting “Treat Warnings As Errors” to “No”.

If you want to build manually, the steps (assuming MSVC is in scope) are:

mkdir build
cd build
cmake ..
cmake --build . --config RelWithDebInfo

MacOS

The following packages are required, as well as CMake and clang. You can install them with homebrew:

brew install pkg-config sdl2

To build the project:

mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo .. 
make -j4

Notes:

Remote server

If you can not build Cardinal3D locally, you can try to build it on Myth server (Rice server does not work for this project). First install latest CMake locally and create an alias for it

pip install cmake --user
alias cmake=~/.local/bin/cmake

Then create the build folder and run the following command to use g++-7.

CC=gcc-7 CXX=g++-7 cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ..

If you are working on MAC, you need to install X Window System XQuartz for ssh X11 forwarding.