Windows and librsvg-2-2.dll

385 views
Skip to first unread message

Lehi Toskin

unread,
Sep 26, 2016, 3:56:58 AM9/26/16
to Racket Users
I've been trying to make asumu's rsvg package working on Windows, but Racket keeps complaining that it cannot find librsvg-2-2.dll. I have verified that the DLL is exporting its symbols, is the correct bit-ness, and is in the right directories - all to no effect. I have have even recompiled it with mingw-w64 just to be sure the DLL wasn't corrupted or something, but that didn't change anything.

As a little test, I made a small DLL in C which was indeed picked up by the FFI and I could use its single function, but I took that same DLL and added an RSVG function, the FFI complained that my DLL was nowhere to be found!

I'm at my wit's end. Is there anything else I could try doing? Could it be there's something wrong with the FFI that would make it incorrectly raise an error or maybe even improperly interact with a DLL?

Matthew Flatt

unread,
Sep 26, 2016, 8:55:00 AM9/26/16
to Lehi Toskin, Racket Users
I see that "librsvg-2-2.dll" has many dependencies, and I bet there's
an issue finding one of the dependencies. As I recall, the error
message from the system will not distinguish between "librsvg-2-2.dll"
not being found and one of its dependencies not being found. That would
explain why you got the "not found" message for your own DLL after
linking to "librsvg-2-2.dll": if "librsvg-2-2.dll" or one of it's
dependencies wasn't found, the error would suggest that your own DLL
wasn't found.

Assuming that you have all of the dependencies in place, my guess is
that it's a question of the search path. When you use `ffi-lib` to load
a DLL, it looks in certain places; when "x.dll" depends on "y.dll",
Windows looks in certain places for "y.dll" as a dependency of "x.dll"
--- and, unfortunately, the latter is a subset of the former places.
Various Racket FFI bindings use the strategy of explicitly loading
"y.dll" before attempting to load "x.dll", so the the previously loaded
"y.dll" satisfies the dependencies of "x.dll".

So, I recommend trying to load the dependencies of "librsvg-2-2.dll"
directly, find out whether each of those works, check dependencies for
one that doesn't work, and so on. (I use Dependency Walker to view DLL
files, and it shows dependencies and dependencies of dependencies in a
nice way.)

Lehi Toskin

unread,
Sep 26, 2016, 12:44:51 PM9/26/16
to Racket Users, lehi....@gmail.com
Using Dependency Walker, it says I'm missing a whole lot of system files. I'll have to investigate this thoroughly.

Doug Williams

unread,
Sep 26, 2016, 4:31:36 PM9/26/16
to Lehi Toskin, Racket Users

I have been tracking them down, too. When I get back home I can send the list I have. I found the dependencies at exwinports on Sourceforge. But, I haven't had time to try it yet.


On Sep 26, 2016 10:44 AM, "Lehi Toskin" <lehi....@gmail.com> wrote:
Using Dependency Walker, it says I'm missing a whole lot of system files. I'll have to investigate this thoroughly.

--
You received this message because you are subscribed to the Google Groups "Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Matthew Flatt

unread,
Sep 26, 2016, 5:35:13 PM9/26/16
to Doug Williams, Lehi Toskin, Racket Users
In case you haven't noticed already, many of the relevant libraries are
distributed with Racket in the "lib" directory. I think they're
probably compiled in a way that's compatible with most
"librsvg-2-2.dll" builds, but if not, the best approach may be to start
with the compilation script in "racket/src/native-libs" and add entries
for new libraries, then cross-compile on a Unix system with MinGW.

At Mon, 26 Sep 2016 14:31:34 -0600, Doug Williams wrote:
> I have been tracking them down, too. When I get back home I can send the
> list I have. I found the dependencies at exwinports on Sourceforge. But, I
> haven't had time to try it yet.
>
> On Sep 26, 2016 10:44 AM, "Lehi Toskin" <lehi....@gmail.com> wrote:
>
> > Using Dependency Walker, it says I'm missing a whole lot of system files.
> > I'll have to investigate this thoroughly.
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Racket Users" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to racket-users...@googlegroups.com.
> > For more options, visit https://groups.google.com/d/optout.
> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users...@googlegroups.com.

Doug Williams

unread,
Sep 26, 2016, 5:54:24 PM9/26/16
to Matthew Flatt, Lehi Toskin, Racket Users
I downloaded librsvg-2.40.1-2-w32-bin.zip from https://sourceforge.net/projects/ezwinports/files/. This contains the file librsvg-2-2.dll and all of its dependencies (18 total dlls). When run with the 32-bit version of Racket (version 6.6) and the rsvg module, this seems to work fine. I assume I would have to recompile them from source, which is also included at ezwinports, for a 64-bit version.

I didn't try a new build script with the dependencies. Many of the dependencies are included with Racket already - I assume because it uses Cairo internally. So, it may not be that many new ones to add. I haven't tracked that down. Would native support for SVG be worth the additional libraries?

Doug

On Mon, Sep 26, 2016 at 3:35 PM, Matthew Flatt <mfl...@cs.utah.edu> wrote:
In case you haven't noticed already, many of the relevant libraries are
distributed with Racket in the "lib" directory. I think they're
probably compiled in a way that's compatible with most
"librsvg-2-2.dll" builds, but if not, the best approach may be to start
with the compilation script in "racket/src/native-libs" and add entries
for new libraries, then cross-compile on a Unix system with MinGW.

At Mon, 26 Sep 2016 14:31:34 -0600, Doug Williams wrote:
> I have been tracking them down, too. When I get back home I can send the
> list I have. I found the dependencies at exwinports on Sourceforge. But, I
> haven't had time to try it yet.
>
> On Sep 26, 2016 10:44 AM, "Lehi Toskin" <lehi....@gmail.com> wrote:
>
> > Using Dependency Walker, it says I'm missing a whole lot of system files.
> > I'll have to investigate this thoroughly.
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Racket Users" group.
> > To unsubscribe from this group and stop receiving emails from it, send an

> > For more options, visit https://groups.google.com/d/optout.
> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an

> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscribe@googlegroups.com.

Doug Williams

unread,
Sep 26, 2016, 6:15:27 PM9/26/16
to Matthew Flatt, Lehi Toskin, Racket Users
Here is a very simple test that just loads an SVG icon from a file and displays it. This runs on my 32-bit version on Racket Version 6.6 (under Windows 10) with the above dlls above. I also included a screen shot.

Doug
Colors.svg
svg-test.rkt
screen-shot.png

Lehi Toskin

unread,
Sep 26, 2016, 7:30:05 PM9/26/16
to Racket Users, mfl...@cs.utah.edu, lehi....@gmail.com
On Monday, September 26, 2016 at 2:54:24 PM UTC-7, m.douglas.williams wrote:
> I downloaded librsvg-2.40.1-2-w32-bin.zip from https://sourceforge.net/projects/ezwinports/files/. This contains the file librsvg-2-2.dll and all of its dependencies (18 total dlls). When run with the 32-bit version of Racket (version 6.6) and the rsvg module, this seems to work fine. I assume I would have to recompile them from source, which is also included at ezwinports, for a 64-bit version.

Ah! I'll try compiling those for amd64 and see how things work out.

Lehi Toskin

unread,
Sep 27, 2016, 5:58:25 AM9/27/16
to Racket Users
I've long since passed the point where pulling my hair out and/or sacrificing virgin goats was the next viable step in my quest to get the libraries working, so I think I'll quit while I'm still coherent and vaguely "sane". It seems as though the bundle of DLL's that m.douglas.williams linked to is what I'll end up using - it's suboptimal because it's 32-bits instead of 64, but I can live with that.

At least until I get it into my head that I *really* want a 64-bit package.

Thank you, everyone, for all your help.

Jens Axel Søgaard

unread,
Sep 27, 2016, 6:25:50 AM9/27/16
to Lehi Toskin, Racket Users
One thing that can go wrong (I think):
  If DrRacket and librsvg both depends on some library a.dll
  and the versions differ then interesting things can happen.
As far as I know it is necessary to use the exact same version.

Google tells me that librsvg depends on Pango so that's one
thing to look out for. 

I had many problems back when I wanted to build Poppler (pdf library).
In the end I resorted to build everything from scratch.

I documented the steps here:


I believe the os x and Linux steps are very similar.

/Jens Axel



--
You received this message because you are subscribed to the Google Groups "Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
--
Jens Axel Søgaard

Reply all
Reply to author
Forward
0 new messages