Thread overview
Using Cairo library bindings on Windows
Sep 28, 2012
KillerSponge
Sep 28, 2012
Andrej Mitrovic
Sep 28, 2012
Andrej Mitrovic
Sep 28, 2012
Andrej Mitrovic
Sep 28, 2012
Andrej Mitrovic
Sep 29, 2012
KillerSponge
Sep 29, 2012
Andrej Mitrovic
Oct 01, 2012
KillerSponge
Oct 01, 2012
Andrej Mitrovic
September 28, 2012
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? :)
September 28, 2012
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.
September 28, 2012
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. :/
September 28, 2012
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.
September 28, 2012
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.
September 29, 2012
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 :)
September 29, 2012
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.
October 01, 2012
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! :)
October 01, 2012
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