This document provides instructions for building OpenSim from source. Please note that steps and settings may vary depending on the configuration of your system. Please also note that building from the source is challenging and, as a non-commercial entity, we have limited resources to provide support for the build process.
In this document, we refer to OpenSim as the collection of C++ libraries and standalone executables distributed under the umbrella name "OpenSim". This does not include the OpenSim application GUI, and the tools necessary to build it and support it (Java, NetBeans, VTK); however, it does include the underlying SimTK dynamics engine (Simbody).
Prerequisites
- Install CMake (2.8), which will generate the build environment for your machine: http://www.cmake.org/cmake/resources/software.html. (You should not need to add CMake to your path)
- If checking out code from the svn repository, install tortoiseSVN for source code control and access to SimTK repositories: http://tortoisesvn.net/downloads.html
- Install Visual C++ 2010 Express Edition freely available from http://www.microsoft.com/visualstudio/en-us/products/2010-editions/visual-cpp-express, if you do not already have VS 2005 or VS 2010 setup on your computer
Install or Build Simbody
You can install the Simbody libraries (binary release) or, if you want to enable debugging of Simbody calls, you can build Simbody from source.
To install Simbody libraries and include files from the binary release:
- Visit http://www.simtk.org and search for the “Simbody” project or go directly to the webpage: https://simtk.org/home/simbody
- Click the Downloads tab on the left-hand side of the page.
- Click on the download for your operating system (Windows, Macintosh, or Linux).
- Install to your computer, by unzipping to a folder of your choice, e.g., C:\Simbody
Below are abbreviated instructions for building Simbody from source. You can find more detailed instructions at the Simbody Project Site. The instruction documents found at the Simbody project site also have lots of helpful information about setting up your system to build, getting cmake, etc.
- Create a local Simbody directory to hold the Simbody source code (e.g. ../MyDocuments/Projects/Simbody)
- Obtain the Simbody source code:
- Using subversion: svn checkout Simbody Trunk from https://simtk.org/svn/simbody/trunk. (Go to the folder you created, right click and select "SVN Checkout". Then enter the url of the repository and verify the name of the local Checkout Directory is the directory you just created. Hit OK)
- Alternately, you can download the Simbody source code in a zip file from the Simbody downloads page.
- Launch cmake:
- Where is the source code? Choose the Simbody source code directory you specified (e.g. ../MyDocuments/Projects/Simbody).
- Where to build the binaries? Choose a build location (e.g. ../MyDocuments/Projects/Simbody/build)
Press the Configure button (near the bottom). Let CMake create the build directory. Choose a “generator” that best matches the compiler you are using, for example “Visual Studio 10”. Select “Use default native compilers” and click Finish.
- Specify an installation location for Simbody (e.g. SimTK_INSTALL_PREFIX = ../MyDocuments/Apps/SimbodyLocal)
Hit Configure again. This time there should be nothing in red and the Generate button will be available.
- Hit "Generate", which will create the Visual Studio solution files in the Simbody build directory
- Go to the directory that you specified as your Simbody build directory. Launch Simbody.sln
- Make sure you are in "Debug" configuration (selection in the top center of the screen).
- Build the project ALL_BUILD (right click and select "Build")
- Build the project INSTALL to make a local installation of binaries (dll’s and exe’s) and documentation.
- Build RUN_TESTS to make sure everything built correctly
- Repeat steps 10 to 12 in the “RelWithDebInfo” configuration. While the debug configuration is very useful for testing and debugging, it will betoo slow to use for most purposes. The production configuration we recommend is RelWithDebInfo. That runs just as fast as Release, but keeps extra debugging information around that can be helpful if you encounter a problem.
Build OpenSim
- Create a local OpenSim directory to hold the OpenSim source code (e.g. ../MyDocuments/Projects/OpenSim)
- Obtain the OpenSim source code:
- Using subversion: svn checkout from https://simtk.org/svn/opensim/Trunk. (Go to the folder you created, right click and select "SVN Checkout". Then enter the url of the repository and verify the name of the local Checkout Directory is the directory you just created. Hit OK)
- Alternately, you can download the OpenSim source code in a zip file from the OpenSim downloads page. (After 3.0 release)
- Launch cmake:
- Where is the source code? Choose the OpenSim source code directory you specified (e.g. ../MyDocuments/Projects/OpenSim). This designates the folder containing the top-level CMake file named CMakeLists.txt.
- Where to build the binaries? Choose a build location (e.g. ../MyDocuments/Projects/OpenSim/build). This designates the folder for compiler files, debug and release sub-folders, etc.
Press the Configure button (near the bottom). Let CMake create the build directory. Choose a “generator” that best matches the compiler you are using, for example “Visual Studio 10”. Select “Use default native compilers” and click Finish.
- To make tests run faster, check BUILD_API_ONLY.
- Specify an installation location for OpenSim (e.g. CMAKE_INSTALL_PREFIX = ../MyDocuments/Apps/OpenSimLocal)
- Verify that NameSpace is blank.
- Point Simbody_INSTALL_DIR to where you installed Simbody (e.g. C:/Apps/SimbodyLocal if you build from source or XXXX if you installed the binary)
Hit Configure again. This time there should be nothing in red and the Generate button will be available.
- Hit "Generate", which will create the Visual Studio solution files in the OpenSim build directory
- Launch OpenSim.sln from the OpenSim build directory
- Make sure you are in "Debug" configuration (selection in the top center of the screen).
- Build the project ALL_BUILD (right click and select "Build")
- Build the project INSTALL to make a local installation of binaries (dll’s and exe’s) and documentation
- Build RUN_TESTS to make sure everything built correctly
- Repeat steps 13 to 15 in the “RelWithDebInfo” configuration. While the debug configuration is very useful for testing and debugging, it will betoo slow to use for most purposes. The production configuration we recommend is RelWithDebInfo. That runs just as fast as Release, but keeps extra debugging information around that can be helpful if you encounter a problem.
- Ensure the OpenSim\bin folder is on a path specified in your computer’s PATH environment variable, (e.g., ensure PATH includes C:\OpenSim Local\bin)
Mac-Specific Instructions
- If you are building on a Mac, set the DYLD_LIBRARY_PATH variable so that the SimTK and OpenSim libraries can be found. (On Windows that is done by setting the system PATH, and on Linux it is done with LD_LIBRARY_PATH.)
- If you are building Simbody on OS X 10.7 (Lion) you will need to use the SDK 10.6 instead of 10.5, and SimTKlapack must be used rather than the Mac native lapack. This is done by changing your cmake configuration as follows:
- Set CMAKE_OSX_DEPLOYMENT_TARGET to "10.6", and CMAKE_OSX_SYSROOT to /Developer/SDKs/MacOSX10.6.sdk"
- Set BUILD_USING_OTHER_LAPACK to "SimTKlapack", and add the Simbody build directory to my DYLD_LIBRARY_PATH
Troubleshooting
- Check out the instructions at the Simbody Project Site. These documents have lots of helpful information about setting up your system to build, getting cmake, etc.