Chapter 1: Installation

[Prerequisites]

OpenTK is a managed library that targets the .Net 2.0 framework. To use it, you will need either the .Net or Mono runtime, plus device drivers for OpenGL (graphics), OpenAL (audio) and OpenCL (compute), depending on the parts of OpenTK you wish to use.

Most operating systems come with a version of the .Net runtime preinstalled, which means OpenTK is typically usable out of the box. In a few cases, you might need to install manually a version of .Net runtime (Windows) or the Mono runtime (Linux/Mac OS X/Windows). Any version equal to or newer than .Net 2.0 / Mono 2.0 will work fine. Earlier versions of Mono may also work, but are no longer supported. Earlier versions of .Net will not work.

Additionally, most recent operating systems come with OpenGL drivers preinstalled. For OpenAL and OpenCL drivers, you should refer to the website of your hardware vendors. [todo: add links to common hardware vendors]

Last, but not least, you will need to download the latest OpenTK release.

[Installation]

OpenTK releases are simple compressed archives. Simply extract the archive contents to a location on your disk and add OpenTK.dll as a reference to your project. You can find OpenTK.dll under the Binaries/OpenTK folder of the OpenTK archive.

Additionally, you should add OpenTK.dll.config to your project and instruct your IDE to copy this file to the output directory. This is necessary for your project to function under Linux and Mac OS X.

The following pages contain specific instructions for using or building OpenTK on different platforms.

Linux

Installing Mono

If you are using a recent Linux distribution, all prerequisites for OpenTK projects should be readily available: the Mono runtime and the Mono compilers. Execute "mono --version" and "gmcs --version" and check if the output looks like this:

$ mono --version
Mono JIT compiler version 1.2.6 (tarball)
Copyright (C) 2002-2007 Novell, Inc and Contributors. www.mono-project.com
        TLS:           __thread
        GC:            Included Boehm (with typed GC)
        SIGSEGV:       altstack
        Notifications: epoll
        Architecture:  amd64
        Disabled:      none
 
$ gmcs --version
Mono C# compiler version 1.2.6.0

If one or both of these commands fail, you'll have to install Mono. Mono packages should be readily available through your package manager:

# Ubuntu and other .deb-based distributions
sudo apt-get install mono mono-gmcs
# or
su -c "apt-get install mono mono-gmcs"
 
# Fedora Core and .rpm-based distributions
su -c "yum install mono mono-gmcs"

If no Mono packages are available, or they are outdated (mono --version returns something less than 1.2.6), you should build Mono from source. There is a message in the support forum describing the process of building mono from source here.

Alternatively, you can find use one of the Mono binary packages on the Mono download page.

Using a binary release

Download the latest opentk-x.y.z-mono.tar.gz release from Sourceforge and untar it:

tar -xvf opentk-0.3.13-mono.tar.gz

A new opentk-x.y.z will be created with four subfolders: "Documentation", "Examples", "Libraries" and "QuickStart". Try running the examples contained in the second folder to make sure everything works alright:

cd opentk-0.3.13/Examples
mono Examples.exe

A new window will hopefully show up, listing all available examples. If not, check the troubleshooting section below.

The "Libraries" folder contains the main OpenTK assembly (OpenTK.dll) and the OpenTK.dll.config file - these are all you need to run OpenTK projects. If you are using MonoDevelop, check the "QuickStart" folder for a ready-to-use project. Last, don't forget to take a look at the release notes contained in the "Documentation" folder.

Troubleshooting

The following error has been reported on Fedora Core 8, when running Examples.exe:

Unhandled Exception: System.TypeInitializationException: An exception was thrown by the type initializer for System.Windows.Forms.Form ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeInitializationException: An exception was thrown by the type initializer for System.Drawing.GDIPlus ---> System.DllNotFoundException: gdiplus.dll
  at (wrapper managed-to-native) System.Drawing.GDIPlus:GdiplusStartup (ulong&,System.Drawing.GdiplusStartupInput&,System.Drawing.GdiplusStartupOutput&)
  at System.Drawing.GDIPlus..cctor () [0x00000] --- End of inner exception stack trace ---

This is caused by a missing entry in "/etc/mono/config". To correct this issue, open the aforementioned file (you must be root!), and add this line: <dllmap dll="gdiplus.dll" target="/usr/lib/libgdiplus.so.0" />. Now, Examples.exe should work.

Building OpenTK from source

OpenTK's build system currently uses NAnt, so you'll need to install that:

# Ubuntu
sudo apt-get install nant
 
# Debian
su -c "apt-get install nant"
 
# Fedora
su -c "yum install nant"

Once that is out of the way, untar the source release and cd to the Build folder:

unzip opentk-0.3.13.zip
cd opentk-0.3.13/Build
mono Build.exe mono

Wait a few seconds for the compilation to end, and check the "Binaries" folder that just appeared in the base OpenTK directory. To build the debug version, append "debug" so that the last command looks like:

mono Build.exe mono debug

[Add an appendix that describes how to build Mono from source, in case there is no package available]

Windows

OpenTK does not come with any installer or setup. Instead, you download the OpenTK binaries and add a reference to "OpenTK.dll" in your Visual Studio/SharpDevelop/MonoDevelop project. (Unzip the binaries first!)

OpenTK demo
To run all of the OpenTK builtin examples, the following software is required:

  1. .NET2.0 or Mono 1.2.6
  2. OpenAL 2.0.3

This is also the software required for an end-user running an OpenTK application. Note that OpenAL is not strictly required if the application does not use any sound.

OpenTK development
If you want to start developing applications using OpenTK, first make sure the items under "OpenTK demo" are installed, then download a compiler/IDE for .NET/mono. Here are some popular choices:

  1. SharpDevelop
  2. MonoDevelop (bundled in the mono installer)
  3. Visual Studio Express

Setting up an OpenTK application in Visual Studio Express
It is a good idea to add "OpenTK.dll.config" to your project, and make sure the "Copy To Output Folder" (not "compile"!) is set to "Copy Always". The application will run without this on Windows, but not on Linux or Mac OS X.

Last, but not least, make sure the "Copy Local" property is set to true for the OpenTK reference, to simplify the distribution of your application.

Setting up an OpenTK application in SharpDevelop
Include the "OpenTK.dll.config" in your project, if you want it to run under Linux Mac OS X.
Visual explanation:

Troubleshooting

Most problems with running OpenTK-based Applications are related to the target platform missing the proper drivers.

OpenTK requires these components installed:

  • Either Mono or .Net (not both).
  • An OpenGL driver for your graphics card.
  • The OpenAL driver for your Operating System.

Below are links for your convenience. Note: Many of those sites require Javascript enabled to function.

Mono

Novell (Linux, Mac & Windows) http://www.go-mono.com/mono-downloads/download.html

.Net

Microsoft (Windows) http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=...

OpenAL

Note: It doesn't matter what brand your soundcard is, just chose the proper Operating System.

Creative Labs (Mac & Windows) http://www.openal.org/downloads.html
Direct link to download page for Windows: http://connect.creativelabs.com/developer/Wiki/OpenAL%20Installer%20for%...
Strangesoft (Linux) http://kcat.strangesoft.net/openal.html

OpenGL

ATi (Linux, Mac & Windows) http://ati.amd.com/support/driver.html
NVIDIA (Linux & Windows) http://www.nvidia.com/Download/index.aspx?lang=en-us
Intel (Windows) http://downloadcenter.intel.com/
Intel (Linux) http://intellinuxgraphics.org/download.html
Mesa 3D (software rendering) http://sourceforge.net/project/showfiles.php?group_id=3

If you have a laptop with an Nvidia card, you can obtain updated drivers through: http://www.laptopvideo2go.com

Last edit of the links: March 2008

Tags for searches:
help problem error outdated trouble crash fail failure exception abort opengl openal driver ati intel nvidia