aBothe / Xwt.Sdl

An SDL2 backend for the XWT framework.
MIT License
2 stars 1 forks source link

Toolkit loading problem. #1

Open phrohdoh opened 10 years ago

phrohdoh commented 10 years ago

It took me an hour or so to get it to compile as the use was not explained too well. But when I finally got it to compile I used "Start Debugging" and get the error... "System.Exception has been thrown, Toolkit could not be loaded" on the line:

Application.Initialize ("Xwt.Sdl.SdlEngine, Xwt.Sdl");

Help please, I'd very much like to use this.

aBothe commented 10 years ago

Nice to see someone wants to use my SDL binding - but it's everything but finished yet! There's quite everything left to do for now!

Okay, I've updated the xwt dependency as well as put in a test sln inside the src/Xwt.Sdl.Test folder to show what's implemented atm. so it's at least buildable and runnable. If you really want to have your own project based on Xwt.Sdl (what I absolutely not recommend atm), you need to include the Xwt.Sdl and the Xwt project as reference in your project. Furthermore on WIndows, you need to copy some sdl.dlls as well. This is how the recent test program finally looks like..not very decent, but well, some basics are there already xwt sdl

aBothe commented 10 years ago

Of course, if you want to contribute something and implement features on your own, I'll do my best to integrate them into the current code base! :)

phrohdoh commented 10 years ago

Alright I'll try and pull your changes and whatnot. I use OSX by the way, I don't know if that changes the dll transferring. As for now I'm just trying to get a window to appear. So far with commenting out that error line and using Toolkit.Gtk, mono launches (nothing on screen) but is "Not Responding."

aBothe commented 10 years ago

Okay, you need to have sdl2 installed anyway - or wait, I think the app config file is missing - which is needed for redirecting SDL2.dll dependency lookups..let me commit it either..sorry for not thinking about that one!

aBothe commented 10 years ago

https://github.com/aBothe/Xwt.Sdl/blob/master/ext/SDL2%23.dll.config

Please experiment with this file - currently I expected the native SDL library and others to be named libSDL2-2.0.0.dylib etc. - so if those files aren't existing anywhere, please correct them and pass me an update if you like :)

phrohdoh commented 10 years ago

Now the line.. (Toolkit.cs ~191)

throw new Exception ("Toolkit could not be loaded", ex);

Gives me the error "System.Exception has been thrown, Toolkit could not be loaded"

aBothe commented 10 years ago

Sure, but there may be plenty of reasons for this..and the most fitting is that the Xwt.Sdl hasn't been put into the binary directory or at least one of its dependencies aren't there..

So did you check the existence and reachability of every .dylib? Recently I had an other guy whose %PATH% didn't contain /usr/local/bin - so in this case, %LD_LIBRARY_PATH% (if that's the lib search path on OSX) isn't containing the directory of the SDL dylibs. Copying the libsdl2 dylib to your bin directory is an option as well! The .dll.config file must be there either! Please just make sure that all files specified for OSX inside the .dll.config are reachable for the program.

phrohdoh commented 10 years ago

Yes yes I apologize, which project should reference the new dylib/dlls? You'll have to forgive me I am still quite inexperienced with git and dependencies for projects. What I currently have is... this So I assume I should copy all of the files from SDL2.Framework into the ext folder, correct?

Edit:

Okay hold on, I installed SDL2, but the only file I have with sdl2 even in the name is that linux .so

aBothe commented 10 years ago

No problem, the Xwt.Sdl project already should have a reference to the .dll.config located in the ext/ folder.

I recommed you just to open up the Xwt.Sdl.Tests solution in XamarinStudio and try to get that one to work. You shouldn't have anything to do furthermore (except downloading the Xwt library via 'git submodule init' and 'git submodule update'). You don't have to copy anything into the /ext folder - everything should be just fine.

Once you've built the Tests project successfully and it's still not executing well, you may have a look at the .dll.config file located in the Xwt.Sdl project (in XS - not via the file manager) and make sure that every .dylib file mentioned in it does exist in your system. If not, you may have to download it from somewhere. If all files do exist, then they might not be reachable for the Tests program.

phrohdoh commented 10 years ago

Where should I get the dylib files? They are not on my system and do not come with the official download/install from the SDL website.

aBothe commented 10 years ago

What is the default dynamic library extension on OSX then? And what files were installed?

phrohdoh commented 10 years ago

dylib is the extension. The only files that came with it were a bunch of cpp headers (.h) and http://i.imgur.com/zsmCDrr.png

aBothe commented 10 years ago

Seems like it's extraordinarily difficult to get SDL2 installed on Mac.. I just googled for 'install sdl on osx' and it brought up a bunch of tutorials on how to do it - I also guess that you've gotta build the libraries on your own..or perhaps ask others on how to manage its installation

phrohdoh commented 10 years ago

Alright I have built all of the dylibs except for libftgl as I was wondering if it would be possible to use SharpFont instead. What I plan on using Xwt.Sdl for already takes advantage of SharpFont and I don't want to introduce anything more than I have to.

Edit:

I don't have libGL but isn't that just part of the standard OpenGL?

aBothe commented 10 years ago

Is it running then?

For the button text, I'm using Cairo's 'toy' font which is just there for trivial/test font rendering - so I was thinking about doing it the Xwt.Gtk way and use Pango, too. But well, SharpFont..never heard of it before. Seems to be good though!

Yep, it's basically opengl - well, it was nice if you could tell me how it's called then on osx so I could change the .dlll.config properly

phrohdoh commented 10 years ago

You have it named correctly, I was just asking.

Unfortunately I still get

System.Exception has been thrown, Toolkit could not be loaded

Which tells me absolutely nothing.

It also turns out that in Xamarin Studio you cannot reference dylibs so I have to have the dlls, which I cannot build on OSX.

aBothe commented 10 years ago

you still need SDL2#.dll for instance for Mono - and for the dylibs, you just can put them into the bin/Debug folder for these primary testing purposes - so no explicit referencing required

phrohdoh commented 10 years ago

Alright I will make copy them into that dir. Also worth nothing when I built ftgl I got libftgl.2.1.3.dylib and a separate libftgl.dylib that has existed on the system for quite some time. I don't know which you prefer to use.

This is the setup I should follow, so I understand some of this project will need to be ported and toyed with.

With everything setup and the dylibs copied I still get that error.

aBothe commented 10 years ago

The first reference can't be working since it's '/Library/Frameworks/SDL2.framework/SDL2', so definitely not a .dylib - Ah, I'm remembering now that Xwt.Sdl also needs libgdiplus because it uses some System.Drawing classes and methods.

phrohdoh commented 10 years ago

Okay but putting this into bin/Debug doesn't change anything at all. libgdiplus.0.dylib was even added and nothing has changed. Shouldn't these be references, not libraries in Debug?

aBothe commented 10 years ago

Hmm. Well there might be some further hidden stuff that couldn't get loaded - why don't you debug the program to see where it exactly wasn't loading?

phrohdoh commented 10 years ago

I am debugging it. That is exactly what I get. It cannot go any further as that error is immediate.

aBothe commented 10 years ago

So try to step through the Initialize toolkit method right at the beginning of the program..there must be a point where it can't load some type or such..

aBothe commented 10 years ago

k, managed to get my hands on the project again. Gonna bring it so far that it'll be able to render my Graphplotter properly.

Btw, I'm using Pango, Glib, Cairo and libgdiplus-based System.Drawing for everything now.