www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Using Cairo library bindings on Windows

reply "KillerSponge" <killersponge gmail.com> writes:
Hi all,

I'm fairly new to D, but so far everything has been going pretty 
smooth. I come from a C(++) background under Linux, so I'm used 
to having to specify the name of the needed .so, and the include 
directory of the headers when using an external library.

I am now trying to build a small D application on Windows to play 
around with Cairo, the graphics library. I found D bindings for 
it in the Deimos repository 
(https://github.com/D-Programming-Deimos/cairo), downloaded the 
dll files from de Cairo website (zlib, libcairo and libpng) and 
put them in the working directory of the project.

When I try to compile the example.d from the Cairo bindings with 
rdmd without specifying anything, I get (as I would expect) a 
whole bunch of "error 42: undefined symbol" errors. But, when I 
try to specify the dll by adding "-L 
{working_dir}\\libcairo-2.dll", I get an "Error 43: Not a Valid 
Library File" message.

I have tried to use the .lib files (which also gives error 43), 
and even tried to convert them using implib, which just results 
in the same bunch of error 42s (at least it's a valid library, I 
suppose?)

As I mentioned, I'm quite new to all this, so it might be 
something really obvious I'm missing, but I'm totally stumped at 
this point. Does anyone here maybe have any idea what the problem 
could be? :)
Sep 28 2012
next sibling parent Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
On 9/28/12, KillerSponge <killersponge gmail.com> wrote:
 snip
Well first of those bindings are broken. The _deprecated.d file is missing a module declaration. Secondly the wrapper module is using extern(System) instead of extern(C) which is why those symbols have 4 appended to them. There are object-oriented multi-platform wrappers for Cairo here: https://github.com/jpf91/cairoD I have some win32 cairo samples on my github page but I have to updated them first, they don't compile anymore (oops!). I'll do this within the hour.
Sep 28 2012
prev sibling next sibling parent Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
On 9/28/12, Andrej Mitrovic <andrej.mitrovich gmail.com> wrote:
 I have some win32 cairo samples on my github page but I have to
 updated them first, they don't compile anymore (oops!). I'll do this
 within the hour.
Man I'm getting linker errors, WinAPI errors when registering WndProc and app crashes on exit. This all used to work fine on 2.058. This will take a longer time to fix, sorry. :/
Sep 28 2012
prev sibling next sibling parent Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
On 9/28/12, Andrej Mitrovic <andrej.mitrovich gmail.com> wrote:
 On 9/28/12, Andrej Mitrovic <andrej.mitrovich gmail.com> wrote:
 I have some win32 cairo samples on my github page but I have to
 updated them first, they don't compile anymore (oops!). I'll do this
 within the hour.
Man I'm getting linker errors, WinAPI errors when registering WndProc and app crashes on exit. This all used to work fine on 2.058. This will take a longer time to fix, sorry. :/
Ok this will be done soon. The linker errors are related to RDMD, I don't know what's up with that I'll figure this out later. WinAPI errors are related to menu's having invalid handles, I've set these to NULL now (I don't know how it worked before). The crashes were related to not disposing a Cairo context before exiting the app. Just a few more minutes and I'm done.
Sep 28 2012
prev sibling parent reply Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
On 9/28/12, Andrej Mitrovic <andrej.mitrovich gmail.com> wrote:
 I have some win32 cairo samples on my github page.
Here you go: https://github.com/AndrejMitrovic/cairoDSamples Just follow the readme instructions.
Sep 28 2012
parent reply "KillerSponge" <killersponge gmail.com> writes:
On Friday, 28 September 2012 at 22:20:54 UTC, Andrej Mitrovic 
wrote:
 On 9/28/12, Andrej Mitrovic <andrej.mitrovich gmail.com> wrote:
 I have some win32 cairo samples on my github page.
Here you go: https://github.com/AndrejMitrovic/cairoDSamples Just follow the readme instructions.
Wow, thank you so much for the quick reply and all the effort! I am going to try this out as soon as I can (which probably won't be until Monday, sorry..) and let you know how it works out :)
Sep 29 2012
parent reply Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
On 9/29/12, KillerSponge <killersponge gmail.com> wrote:
 Wow, thank you so much for the quick reply and all the effort! I
 am going to try this out as soon as I can (which probably won't
 be until Monday, sorry..) and let you know how it works out :)
No problem. I also have some samples written that use the naked C API (meaning not the OOP CairoD wrapper but a C-API wrapper similar to the one from deimos). If you need those too I'll post them to github.
Sep 29 2012
parent reply "KillerSponge" <killersponge gmail.com> writes:
On Saturday, 29 September 2012 at 15:55:44 UTC, Andrej Mitrovic 
wrote:
 No problem. I also have some samples written that use the naked 
 C API
 (meaning not the OOP CairoD wrapper but a C-API wrapper similar 
 to the
 one from deimos). If you need those too I'll post them to 
 github.
I just tested the examples and built my own small test project with your bindings, they are working great! Thank you so much! :)
Oct 01 2012
parent Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
On 10/1/12, KillerSponge <killersponge gmail.com> wrote:
 I just tested the examples and built my own small test project
 with your bindings, they are working great! Thank you so much! :)
Cool, I'm glad it works for you. Btw there is a new version of Cairo out but I think CairoD hasn't yet been updated. If that's an issue feel free to file a bug so we don't forget to upgrade sometime later: https://github.com/jpf91/cairoD
Oct 01 2012