Skip to content
Jacob Austin edited this page Aug 2, 2018 · 51 revisions

Windows Installation:

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

Step-by-Step installation process

1. 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.

Note: do not download VS 2017, there are several incompatibilities with CUDA and only Visual Studio 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. 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 "Loch" folder using:
git clone https://github.com/ja3067/Loch.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 Loch library. Copy this somewhere. Then navigate to the Loch download from step 3 and copy the Loch/vcpkg/loch folder to vcpkg/ports. Then zip the entire Loch directory and copy it to vcpkg/downloads/Loch.zip (you may need to create the downloads folder). Then from the vcpkg directory run:

./vcpkg install --triplet x64-windows loch

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.

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. This is the path you saved earlier in the process.

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

  • 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. It is recommended to use Visual Studio 2017 with CMake support, opening your project as a CMake project. In Visual Studio, go to CMake/CMake Settings and generate a cmake settings JSON file for your project. In this file, under the x64-debug and x64-release targets, 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.

Uninstalling

To remove the loch library, simply run

./vcpkg remove loch --triplet x64-windows

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

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

or install vcpkg, copy the loch directory into the ports folder, copy the zip, and run ./vcpkg install loch.

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

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.

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

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.