Skip to content
Jacob Austin edited this page Oct 27, 2018 · 51 revisions

Windows Installation:

  • Install Microsoft Visual Studio 2015 or 2017
  • Install the NVIDIA CUDA Toolkit
  • Install vcpkg and add the portfile
  • Build and install the library
  • (Optional) Set up CLion or Visual Studio to use the library

Step-by-Step installation process

1a. Install Microsoft Visual Studio 2015

Download Microsoft Visual Studio Community 2015 (with Update 3) from the provided link and follow the installer instructions to install the Visual C++ compiler and v140 toolkit. You do not need to install the Visual Studio IDE or any other tools (only Visual C++ tools). You may need to subscribe for free to My Visual Studio to access older versions.

1b. Install Microsoft Visual Studio 2017

Download Microsoft Visual Studio Community 2017 from Microsoft (link) and follow the installer instructions to install the Visual C++ compiler and v140 toolkit. You do not need to install the Visual Studio IDE or any other tools (only Visual C++ tools), although you may want to install the IDE if you prefer to develop in Visual Studio over CLion.

Once Visual Studio 2017 is installed, you will have to make a few changes to let it interface with CUDA. You will need to

  1. Open C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.2\include\crt\host_config.h
  2. Find the line #if _MSC_VER < 1600 || _MSC_VER > 1913 and replace it with just #if _MSC_VER < 1600

For some reason, CUDA is made incompatible with newer versions of Visual Studio, but disabling this has no adverse effects.

2. Install NVIDIA CUDA

Download the NVIDIA CUDA Toolkit from the provided link and follow the quick install instructions. If the installation fails, try again using the advanced installation tab and unchecking Visual Studio Integration. This is a known CUDA big caused by incompatibilities with some Visual Studio versions.

3. Download the library

The library does not provided any binaries in the repository, but they can be built using CMake and vcpkg. To do so,

  • Navigate to a directory on your computer where you want the library to be stored. Then run the git clone command to download the repository to a "Titan" folder using:
git clone https://github.com/ja3067/Titan.git

4. Install vcpkg and the library

We will be using the vcpkg utility to handle dependencies for this project. The library optionally supports graphics rendering of the mass spring simulation using OpenGL, with utilities provided by the GLM, GLEW, and GLFW libraries. These libraries can be installed in any fashion, but the Microsoft vcpkg package manager provides a convenient method. To use vcpkg,

  1. Go to the vcpkg GitHub and clone the repository into your user account (ideally in C:/vcpkg or C:/Users/.../Documents) using the following:
cd C:/
git clone https://github.com/Microsoft/vcpkg.git
  1. Then follow the installation/setup instructions provided in the GitHub (reproduced here) and install the dependencies:
cd vcpkg
./bootstrap-vcpkg.bat
./vcpkg integrate install

The last command will output a path to the vcpkg cmake file which you will need to include in future projects to use the Titan library. Copy this somewhere. Then navigate to the Titan download from step 3 and copy the Titan/vcpkg/titan folder to vcpkg/ports. Then zip the entire Titan directory and copy it to vcpkg/downloads/Titan.zip (you may need to create the downloads folder). Then from the vcpkg directory run:

./vcpkg install --triplet x64-windows titan

This will download and install all the necessary dependencies into the vcpkg install folder. Everything is now installed, and you can use it to build a simple project. See the next page.

5. (Optional) Using CLion or Visual Studio

CLion

CLion is a cross-platform IDE developed by IntelliJ, the creators of PyCharm and IDEA. The IDE uses CMake by default, so it is ideal for including our CMake project. To build and run your project with CLion, several settings changes need to be made.

  1. First, in Settings/Build, Execution, Deployment/CMake, make sure CMake Options includes the command
-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake

where the path points to the vcpkg folder. If you have vcpkg installed in a different directory, use that path instead. This is the path you saved earlier in the process.

  1. Make sure the compiler in Settings/Build, Execution, Deployment/Toolchains is set to Visual Studio 2015 or 2017 (14.0), and the architecture is set to 64-bit (amd64 on Windows). Do not use amd64_arm or any other compiler option.
  • Note that there is sometimes a bug in CLion with CUDA support that causes it to run the wrong executable - if CLion is unable to run an executable, manually run the executable found in the project directory (it will be found in the cmake-build-debug or cmake-build-release folder depending on your settings).

  • Note that CLion will sometimes find the library installed in the wrong directory, not the vcpkg version. If CLion is unable to find the library, or seems to have found the wrong version, try navigating to Program Files and Program Files (x86) and deleting any folder called "Titan". Then reload the CMake project (using File/Reload CMake Project). Sometimes you will also need to delete the cmake-build-debug folder, close CLion, and then reopen it and run File/Reload CMake Project.

Visual Studio

To use Visual Studio, ironically, it is recommended to use Visual Studio 2017 with CMake support, opening your project as a CMake project. However, there may be incompatibilities with CUDA, depending on the version, which make it difficult to use. If it is unable to find CUDA, try manually setting the toolchain version to v140 (you may need to install this version using the Visual Studio compiler). There are again some compatibility steps you may need to take to get Visual Studio to interface with vcpkg.

  1. In Visual Studio, go to CMake/CMake Settings and generate a CMakeSettings.json file for your project. In this file, under the x64-debug and x64-release targets, you may need to add the variables section of the following example.
{
      "name": "x64-Release",
      ...,
      "variables": [
             {
               "name": "CMAKE_TOOLCHAIN_FILE",
               "value": "${env.VCPKG_DIR}"
             }
     ]
}

If this fails, change env.VCPKG_DIR to the actual path to the vcpkg directory.

  1. If you are unable to get Visual Studio 2017 to work, use Visual Studio 2015, but manually copy the Titan.dll dynamic library from the vcpkg/installed directory into your project directory. Then you should be able to include the headers found in the vcpkg/installed directory and link to the library file.

Uninstalling

To remove the titan library, simply run

./vcpkg remove titan --triplet x64-windows

It can be reinstalled at any time using ./vcpkg install titan --triplet x64-windows. If you want to repeat this process with a new build of the Titan library, you will need not only to remove the vcpkg installation, but also delete the decompressed source code in vcpkg/buildtrees/titan. Then recopy the zip and reinstall.

Linux Installation:

Linux installation is very similar. Just download vcpkg, copy the zip into the downloads directory in vcpkg, and then run

./vcpkg install titan

which will handle all of the dependencies for you. At the moment, due to a bug, you may need to include the line

project(myproject LANGUAGES CXX CUDA)

in whatever project uses our library. This is because certain environment variables which are needed by the library are not being set properly. In some cases, if CMake cannot find CUDA, you will need to manually set

set(CMAKE_CUDA_COMPILER /usr/local/cuda/bin/nvcc)

or whatever the path to the CUDA nvcc compiler is.

Mac OS Installation:

Mac OS installation is virtually identical.

brew install glfw3 glm GLEW # must have homebrew installed
git clone https://github.com/ja3067/Titan.git
cd Titan
mkdir build
cmake ..
make install

Mac OS graphics are currently experimental, and may not work. Use with Mac OS is not currently recommended since few if any Apple computers have Nvidia graphics cards. If you have a Mac OS computer which ought to be supported, send me a message. It is possible, but may requiring some refactoring of the graphics, since Mac OS is very restrictive with multithreading and OpenGL.

Testing your installation:

The library comes with several tests which demonstrate basic aspects of the program. To run the tests on Linux or Mac, navigate to Titan/tests and run

mkdir build
cd build
cmake ../test1 -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake # this should be the path to vcpkg
make
./test1
cmake ../test2 -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake # this should be the path to vcpkg
make
./test2

Both tests should display a bouncing ball which should close after 10 seconds (if graphics are enabled). These two tests are designed to test the CUDA integration and the integrity of the installation. Now you are ready to include the library in your own project. To do this, see the Tutorials section.

To run these on Windows, open the tests/test1 or tests/test2 directories in CLion or some other IDE which supports CMake (Visual Studio 2017 should work for this) and build and run the projects.