Skip to content
Jacob Austin edited this page Jul 13, 2018 · 51 revisions

Windows Installation:

  • Install Microsoft Visual Studio 2015 (Visual Studio 2017 does not work with CUDA, currently)
  • Install the NVIDIA CUDA Toolkit
  • (Optional) Install graphics dependencies using vcpkg
  • Build and install the library

Step-by-Step installation process

1. Install Microsoft Visual Studio 2015

Download Microsoft Visual Studio 2015 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.

Note: do not download VS 2017, there are several incompatibilities with CUDA and only VS 2015 is guaranteed to work. You may need a free Microsoft Developer account to download VS 2015. We are working to resolve this issue, but VS 2015 is the only stable release which is guaranteed to be compatible with CUDA.

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. (Optional) Install graphics dependencies

Note: this step can be skipped if the user only intends to use the library without graphics functionality. Simply skip to the "Building the Library" section below

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) 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
./vcpkg --triplet x64-windows install glfw3 GLEW glm

This will download and install all the necessary dependencies into the vcpkg install folder.

4. Download the library

The library does not provided any binaries in the repository, and they must be built and installed using CMake. 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 "Loch" folder using:
git clone https://github.com/ja3067/Loch.git

5. Build the library

To build the library, you can either use CMake from the GUI or command line, or using the CLion or Visual Studio IDEs.

Using CMake:

To use CMake without an IDE, run one of the following, depending on whether you want to build the graphics capability. This may require administrative privileges. The CMake step can also be performed using the CMake GUI version by specifying the CMAKE_TOOLCHAIN_FILE explicitly in the CMake GUI instead of as a command-line argument.

To enable graphics:

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

Without graphics:

mkdir build
cd build
cmake .. -DNOGRAPHICS
make install

This may take a few minutes. This will build the library and copy the relevant files to a central directory on your computer (on Windows, this is C:/Program Files/Loch, on Mac and Linux /usr/local/include/Loch). Now you can include it in other projects.

Using CLion

To build and run with CLion, several settings changes need to be made.

  1. First, in Settings/Build, Execution, Deployment/CMake, make sure CMake Options is set to "-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake" (i.e. the path to the vcpkg folder, no quotes). Note: If you have vcpkg installed in a different directory, use that path instead.

  2. 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).

Next, open the Loch project in CLion. Make sure to open CLion as an administrator when you build the library. Windows requires admin privileges to install the library in the Program Files directory. Once CMake has finished building, click Run/Install to build and install the library for future use.

  • Note that there is 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 executables in the project directory.

Using Visual Studio

To use Visual Studio, please see the requirements in the Using CMake or Visual Studio page. You must either open the Loch project as a CMake project in Visual Studio (only supported in the 2017 IDE) or manually specify dependencies on your computer (namely OpenGL, GLFW, GLM, GLEW, and CUDA). You will need to specify include directories and library locations.

Linux Installation:

Linux installation is much simpler. Simply run

sudo apt-get install glfw3 glm GLEW # or your distribution's package manager.
git clone https://github.com/ja3067/Loch.git
cd Loch
mkdir build
cmake ..
make install

Mac OS Installation:

Mac OS installation is virtually identical.

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

Testing your installation:

The library comes with several tests which demonstrate basic aspects of the program. To run the tests, navigate to Loch/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.