Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create an alien module for Image::Magick #142

Open
hakonhagland opened this issue Oct 12, 2023 · 4 comments
Open

Create an alien module for Image::Magick #142

hakonhagland opened this issue Oct 12, 2023 · 4 comments

Comments

@hakonhagland
Copy link

hakonhagland commented Oct 12, 2023

Continuing the discussion from here: #139 (comment), #139 (comment) and #139 (comment)

The list of DLL dependencies can be obtained using App::PP::AutoLink. Use that to pack a perl file that uses Image::Magick. The list of detected DLLs is printed to the console and can then be edited to copy the needed files to a new location.

The advantage of the Alien approach is that it saves the files under .../site/lib/auto/share. The Alien package then adds itself to the path when it is used on the right OS and build type, and is a no-op otherwise (at least that's how I've implemented Alien::GtkStack::Windows). One could also probably use File::ShareDir directly but the Alien infrastructure makes installation and use easier.

Alien::ImageMagick uses an older style approach that also does not work on Windows since it uses Unix syntax. It should be possible to update it to use Alien::Build but there would still be the need to get all the dependencies in place. That is perhaps best done using a second Alien, or it could be done as a build step on Windows.

@shawnlaffan Looks like a good idea, I am creating an issue here so we can track it. I will investigate App::PP::AutoLink and come back here when I know more.

@hakonhagland
Copy link
Author

I used the installation of Image::Magick in #139 (comment)

Then, I created a test script:

use feature qw(say);
use strict;
use warnings;
use Image::Magick;

my $img=Image::Magick->new();
$img->Read('logo:');
$img->Write("logo.png");
say "Done.";

and ran pp_autolink on that file:

> pp_autolink.bat p.pl
DLL check iter: 1
DLL check iter: 2
DLL check iter: 3
DLL check iter: 4
No alien system dlls detected

Detected link list: c:/strawberry/c/bin/libmagickcore-7.q16hdri-10.dll c:/strawberry/c/bin/libdl.dll c:/strawberry/c/bin/libbz2-1__.dll c:/strawberry/c/bin/libgomp-1.dll c:/strawberry/c/bin/libjpeg-9__.dll

Detected aliens:

CMD: pp --link c:/strawberry/c/bin/libmagickcore-7.q16hdri-10.dll --link c:/strawberry/c/bin/libdl.dll --link c:/strawberry/c/bin/libbz2-1__.dll --link c:/strawberry/c/bin/libgomp-1.dll --link c:/strawberry/c/bin/libjpeg-9__.dll p.pl

Does this mean that we only need to pack the following 5 libraries?

  • c:/strawberry/c/bin/libmagickcore-7.q16hdri-10.dll
  • c:/strawberry/c/bin/libdl.dll
  • c:/strawberry/c/bin/libbz2-1__.dll
  • c:/strawberry/c/bin/libgomp-1.dll
  • c:/strawberry/c/bin/libjpeg-9__.dll

@shawnlaffan
Copy link
Contributor

shawnlaffan commented Oct 12, 2023

Does this mean that we only need to pack the following 5 libraries?

It should only need those not ending in "__.dll" as those are part of Strawberry Perl (32 bit appends one underscore, 64 bit does two).

Although libdl and libgomp-1 are both part of the strawberry perl distribution so they too are not needed. (They are originally from winlibs and we decided to leave them in).

So that means it should only need libmagickcore-7.q16hdri-10.dll.

Edit - I think that is also consistent with what @sisyphus reported in #140 (comment)

@hakonhagland
Copy link
Author

hakonhagland commented Oct 14, 2023

Refer to #139 (comment) :

The limitation is that each calling script needs a use Alien::XYZ statement at the top, or the PERL5OPT variable needs to be updated.

@shawnlaffan Interesting. Is it also correct that a third option (and maybe the best?) would be to have Gtk2 (in the form of an accepted PR) use Alien::GtkStack::Windows ? Then, when installing Gtk2 with for example cpanm Gtk2, Alien::GtkStack::Windows would also be installed automatically if missing..

@shawnlaffan
Copy link
Contributor

In principle yes, but there are always complexities.

The builds need manual intervention at the moment, per the method @sisyphus worked out in https://www.perlmonks.org/?node_id=11153992 but this is a step forward.

In one scenario such an Alien would compile from source rather than munging MSYS2 files. The number of extra dependencies is high, though, which leads to more Aliens.

There's also the possibility of compiling the various dependencies using the approach we use for the Strawberry Perl deps (see https://github.com/StrawberryPerl/build-extlibs).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants