seoushi's picture

Can't build on OS X

I'm not sure if this is mono related or mac related error but here is what I did.

Extracted the zip, went into Build via the terminal and ran "mono Build.exe mono" it runs fine until OpenTK.dll is trying to be made. Here is the relevant output

 
[csc] ** (/Library/Frameworks/Mono.framework/Versions/1.2.6/lib/mono/2.0/gmcs.exe:19216): WARNING **: The class Mono.WebBrowser.DOM.IDocument could not be loaded, used in Mono.Mozilla, Version=0.2.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756
                  [csc] ** (/Library/Frameworks/Mono.framework/Versions/1.2.6/lib/mono/2.0/gmcs.exe:19216): WARNING **: The class Mono.WebBrowser.DOM.IElement could not be loaded, used in Mono.Mozilla, Version=0.2.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756
                  [csc] ** (/Library/Frameworks/Mono.framework/Versions/1.2.6/lib/mono/2.0/gmcs.exe:19216): WARNING **: The class Mono.WebBrowser.DOM.IWindow could not be loaded, used in Mono.Mozilla, Version=0.2.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756
                  [csc] Unhandled Exception: System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be loaded.
                  [csc]   at (wrapper managed-to-native) System.Reflection.Assembly:GetTypes (bool)
                  [csc]   at System.Reflection.Assembly.GetExportedTypes () [0x00000] 
                  [csc]   at Mono.CSharp.TypeManager.LoadAllImportedTypes () [0x00000] 
                  [csc]   at Mono.CSharp.Driver.MainDriver (System.String[] args) [0x00000] 
                  [csc]   at Mono.CSharp.Driver.Main (System.String[] args) [0x00000] 
 
            BUILD FAILED - 0 non-fatal error(s), 68 warning(s)
 
            /Users/seoushi/Desktop/opentk-0.9.0/Source/OpenTK/OpenTK.dll.build(10,10):
            External Program Failed: /Library/Frameworks/Mono.framework/Versions/1.2.6/lib/mono/2.0/gmcs.exe (return code was 1)

I'm curious where in the code Mono.WebBrower.DOM.IWindow is referenced (or what would be calling it). Also is there anyway for the build to be more verbose like what file is causing the exception?


Comments

Comment viewing options

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

I remember seeing this very error somewhere (the mono mailing-list, I think), but haven't been able to find details yet. I think it has something to do with the installation of Mono or System.Windows.Forms - OpenTK doesn't use Mono.WebBrowser.

Are you able to build other Mono applications? For example, the following code:

using System.Windows.Forms;
 
class Test
{
	public static void Main()
	{
		using (Form f = new Form())
		{
			f.Visible=true;
			Application.Run(f);
		}
	}
}

If this doesn't work, you can try to reinstall/rebuild Mono. Mono 1.9 should also see the light of day this week, and will hopefully fix the issue if it is caused by Mono.

In any case, there is no need to recompile OpenTK, unless you plan to hack at the source (the existing binaries will run fine on OS X). Just a small note that OS X is only supported through X11 at this point. I've cleaned up much of the internal code for 0.9.1, but when the actual port will happen depends on whether an interested party shows up. :)

seoushi's picture

I can build and run that code just fine. The reason I tried building the dll is because I was having uses with the prebuilt one.

When I try to run my program via xterm I get.

 mono Client.exe --config OpenTK.dll.config 
 
Unhandled Exception: System.DllNotFoundException: libGL.so.1
  at (wrapper managed-to-native) OpenTK.Platform.X11.Glx:ChooseVisual (intptr,in
t,intptr)
  at OpenTK.Platform.X11.Glx.ChooseVisual (IntPtr dpy, Int32 screen, System.Int3
2[] attriblist) [0x00000] 
  at OpenTK.Platform.X11.X11GLContext.OpenTK.Platform.IGLContextCreationHack.Sel
ectDisplayMode (OpenTK.DisplayMode mode, IWindowInfo info) [0x00000] 
  at OpenTK.Platform.X11.X11GLNative.CreateWindow (OpenTK.DisplayMode mode, IGLC
ontext& glContext) [0x00000] 
  at OpenTK.GameWindow.CreateWindow (OpenTK.DisplayMode mode, System.String titl
e) [0x00000] 
  at OpenTK.GameWindow..ctor (OpenTK.DisplayMode mode, System.String title) [0x0
0000] 
  at OpenTK.GameWindow..ctor (OpenTK.DisplayMode mode) [0x00000] 
  at Client.Engine..ctor (Int32 height, Int32 width) [0x00000] 
  at Client.Program.Main () [0x00000]

my OpenTK.dll.config consists of

<configuration>
 
  <dllmap dll="opengl32.dll" target="/System/Library/Frameworks/OpenGL.framework/OpenGL"/>
 
  <dllmap dll="glu32.dll" target="/System/Library/Frameworks/OpenGL.framework/OpenGL"/>
 
  <dllmap dll="openal32.dll" target="/System/Library/Frameworks/OpenAL.framework/OpenAL"/>
 
  <dllmap dll="alut.dll" target="/System/Library/Frameworks/OpenAL.framework/OpenAL"/>
 
</configuration>

Also I would more then willing to help getting OpenTK working on OS X. It's just a matter of what needs to be done and how. I'm not really versed in cocoa so it might be a little tough.

test bot's picture

Try adding the following line to OpenTK.dll.config:

<dllmap dll="libGL.so.1" target="/System/Library/Frameworks/OpenGL.framework/OpenGL"/>

Glx functions are currently hardcoded to use libGL.so.1.

seoushi's picture

When I add that line I no longer get the dll not found except but rather another.

bash-3.2$ mono Client.exe --config OpenTK.dll.config 
 
Unhandled Exception: System.EntryPointNotFoundException: glXChooseVisual
  at (wrapper managed-to-native) OpenTK.Platform.X11.Glx:ChooseVisual (intptr,in
t,intptr)
  at OpenTK.Platform.X11.Glx.ChooseVisual (IntPtr dpy, Int32 screen, System.Int3
2[] attriblist) [0x00000] 
  at OpenTK.Platform.X11.X11GLContext.OpenTK.Platform.IGLContextCreationHack.Sel
ectDisplayMode (OpenTK.DisplayMode mode, IWindowInfo info) [0x00000] 
  at OpenTK.Platform.X11.X11GLNative.CreateWindow (OpenTK.DisplayMode mode, IGLC
ontext& glContext) [0x00000] 
  at OpenTK.GameWindow.CreateWindow (OpenTK.DisplayMode mode, System.String titl
e) [0x00000] 
  at OpenTK.GameWindow..ctor (OpenTK.DisplayMode mode, System.String title) [0x0
0000] 
  at OpenTK.GameWindow..ctor (OpenTK.DisplayMode mode) [0x00000] 
  at Client.Engine..ctor (Int32 height, Int32 width) [0x00000] 
  at Client.Program.Main () [0x00000]
the Fiddler's picture

So it finds the shared object, but it doesn't contain this function... I'm trying to find which .so contains glXChooseVisual in OSX, but no success yet - any ideas?

It's a bit strange, since there are people who have gotten OpenTK to work under OSX/X11, without needing to modify the dll.config.

seoushi's picture

One thing I can think of is that this program was compiled under windows on visual studio 2008 (set to .net 2.0 instead of the default 3.5). As for the function not found the only thing I can think of is that there is a special glx library for x11 that isn't part of standard opengl library. I'm going to look into it more myself.

the Fiddler's picture

I don't think vs2008 is causing problems - I've tested compiled binaries quite extensively on Linux/Mono, with no ill-effects visible.

Edit: A bit tangential, but a quick overview of a potential native port:

There are five main "areas" to implement: mode selection, window creation, context creation, input handling, and extension loading (I'll draw a quick class diagram tomorrow).

Extension loading is already implemented. The rest involve implementing specific interfaces (e.g. IGraphicsContext, INativeGLWindow). I've taken the time to clean things up for 0.9.1, so these are mostly independent. GLFW can act as an excellent guide to the low-level implementation, while Mono also contains an OSX driver for Windows.Forms. Both will prove useful.

I don't currently have access to a Mac, but I can help with the pinvokes, the design and the implementation of the system. It's not an easy endeavour, but it's manageable! :)

seoushi's picture

I know that SDL.net runs natively on os x as well. It might be worth looking into. Either way I'm looking forward to the diagrams. I can promise anything but I will try.

kanato's picture

I got AgateLib to run on OS X using an older version of OpenTK a while back. I think your issue is that OSX has a separate version of OpenGL for use with X11 in /usr/X11R6/lib. My config file was something like:

<configuration>
  <dllmap dll="opengl32.dll" os="osx" target="/usr/X11R6/lib/libGL.dylib"/>
  <dllmap dll="libGL.so.1" os="osx" target="/usr/X11R6/lib/libGL.dylib"/>
  <dllmap dll="glu32.dll" os="osx" target="/usr/X11R6/lib/libGLU.dylib"/>
</configuration>
seoushi's picture

Strangley enough that gives me another error..

Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object
at OpenTK.Platform.X11.X11GLNative.CreateWindow (OpenTK.DisplayMode mode, IGLContext& glContext) [0x00000]
at OpenTK.GameWindow.CreateWindow (OpenTK.DisplayMode mode, System.String title) [0x00000]
at OpenTK.GameWindow..ctor (OpenTK.DisplayMode mode, System.String title) [0x00000]
at OpenTK.GameWindow..ctor (OpenTK.DisplayMode mode) [0x00000]
at Client.Engine..ctor (Int32 height, Int32 width) [0x00000]
at Client.Program.Main () [0x00000]