CheatCat's picture

[Solved] Using OpenTK at Linux?

I tried the run my game at Linux, but I only get this error:
"The type or namespace name `OpenTK' could not be found. Are you missing a using directive or an assembly reference?(CS0246)]"

And I have the OpenTK dll in the bin\Debug directory. Should I make a new dll in Linux? (I use the one I compiled in Windows)

A have another question also: How I do a Linux executable file?


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
the Fiddler's picture

This is a compilation error, not a runtime error. Are you using MonoDevelop? Have you added OpenTK.dll to your project references? Have you added OpenTK.dll.config to your project and enabled the "copy to output directory" option?

To answer your question, OpenTK works out of the box on Linux, you don't have to recompile or anything.

Edit: 'gmcs' is the C# compiler for Mono. It creates executables by default.

Install MonoDevelop to get a full-featured IDE. MonoDevelop uses Visual Studio projects, so you can move from Windows <-> Linux painlessly.

On Ubuntu:

sudo apt-get install monodevelop monodevelop-versioncontrol monodevelop-debugger-mdb monodevelop-debugger-gdb

Type this line on a terminal to get a full-feature environment for .Net development.

CheatCat's picture

Yes, I use MonoDevelop and I do what you say. I try to run the QuickStart program but it ends quickly after running it. Then I test Debug mode and get a black window. There is a yellow pile that point at VSync = VSyncMode.On; in the function:

public Game() : base(800, 600, GraphicsMode.Default, "OpenTK Quick Start Sample")
            VSync = VSyncMode.On;

But I see no errors... I removed the VSync line and the yellow pile point at the } instead. It something wrong with public Game() : base(800, 600, GraphicsMode.Default, "OpenTK Quick Start Sample") I think..

the Fiddler's picture

Need more information:

  • Version of OpenTK
  • Your operating system (including whether it is x86 or amd64)
  • The application output when QuickStart is compiled against the debug version of OpenTK: remove OpenTK from the references in QuickStart and add the debug version of OpenTK.dll. The output appears in the "Application Output" window at the bottom of MonoDevelop.
CheatCat's picture

The version of OpenTK is.. 0.9.7, I think. My OS is Kubuntu 9.04 x86.

The output:

Module QuickStart, Version=, Culture=neutral, PublicKeyToken=null loaded.
Module OpenTK, Version=, Culture=neutral, PublicKeyToken=null loaded.
Module System, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089 loaded.
Module OpenTK.Utilities, Version=, Culture=neutral, PublicKeyToken=null loaded.
Module System.Drawing, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a loaded.
Module System.Windows.Forms, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089 loaded.
Module System.Configuration, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a loaded.
Module System.Xml, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089 loaded.
Unhandled Exception: System.DllNotFoundException: opengl32.dll
  at (wrapper managed-to-native) GetProcAddressX11:glxGetProcAddress (string)
  at OpenTK.Graphics.GL+GetProcAddressX11.GetProcAddress (System.String function) [0x00000] 
  at OpenTK.Graphics.GL.GetAddress (System.String function) [0x00000] 
  at OpenTK.Graphics.GL.GetExtensionDelegate (System.String name, System.Type signature) [0x00000] 
  at OpenTK.Graphics.GL.LoadDelegate (System.String name, System.Type signature) [0x00000] 
  at OpenTK.Platform.Utilities.LoadExtensions (System.Type type) [0x00000] 
  at OpenTK.Graphics.GL.LoadAll () [0x00000] 
  at OpenTK.Platform.X11.X11GLContext.OpenTK.Graphics.IGraphicsContextInternal.LoadAll () [0x00000] 
  at OpenTK.Graphics.GraphicsContext.OpenTK.Graphics.IGraphicsContextInternal.LoadAll () [0x00000] 
  at OpenTK.GameWindow..ctor (Int32 width, Int32 height, OpenTK.Graphics.GraphicsMode mode, System.String title, GameWindowFlags options, OpenTK.Graphics.DisplayDevice device, Int32 major, Int32 minor, GraphicsContextFlags flags) [0x00000] 
the Fiddler's picture

It seems that OpenTK.dll.config is missing. This file should be in the same directory as OpenTK.dll, because otherwise OpenTK won't work on Linux/Mac OS X.

CheatCat's picture

Okey, I get it! :D But how I start my program stand-alone? If I double-click at the exe file, it opens with Wine and don't run at all (but it run in Mono at debugmode)!

the Fiddler's picture

Right click and select 'open with mono'. If there's no such option, use 'open with other application' and type 'mono' as the application.

You could also create an executable script that simply calls 'mono App.exe' (where App.exe is the name of your application).

CheatCat's picture

But then you must have mono on every computer with Linux you that to play the game on?

the Fiddler's picture

Obviously, yes. Developing for the .Net framework means you are dependent on .Net on Windows and Mono on Linux / Mac OS X.

CheatCat's picture

Oh, thank you! :D