rschupp / PAR-Packer

(perl) Generate stand-alone executables, perl scripts and PAR files https://metacpan.org/pod/PAR::Packer
Other
48 stars 13 forks source link

Strawberry Perl pp: install_driver(mysql) failed: Can't load #71

Closed ghost closed 1 year ago

ghost commented 1 year ago

install_driver(mysql) failed: Can't load 'C:\Users\console\AppData\Local\Temp\2\par-636f6e736f6c65\cache-ee29a3cd85eb611c8a00b9972a27e709b24ef593\bc4e1068.xs.dll' for module DBD::mysql: load_file:The specified module could not be found at /DynaLoader.pm line 193. at /PAR/Heavy.pm line 140. Compilation failed in require at (eval 16) line 3. Perhaps a required shared library or dll isn't installed where expected at script/test_mysql.pl line 2.

bc4e1068.xs.dll exists in the cache directory with read, write, full control permissions.

The build command is pp -o test_mysql.exe test_mysql.pl I have tried -x -c, --link c:\Strawberry\perl\vendor\lib\auto\DBD\mysql\mysql.xs.dll and --module=DBD::mysql with no success.

The test_mysql.exe works on computers with Strawberry Perl installed, so I don't think it is a mysql.xs.dll issue. Testing with DBI:ODBC:driver={SQL Server} works.

The test program is use DBI; my $dbh = DBI->connect("DBI:mysql:database=shoreware", '', '' ) || die("Database connect fail: $!; DBI error = $DBI::errstr\n");

Normal Strawberry perl distribution: osname=MSWin32 osvers=10.0.19042.746 archname=MSWin32-x64-multi-thread uname='Win32 strawberry-perl 5.32.1.1 #1 Sun Jan 24 15:00:15 2021 x64'

PAR Packager, version 1.057 (PAR version 1.018) DBD::mysql is up to date (4.050). DBI is up to date (1.643).

I am at a loss as to why DynaLoader is failing with the package.

rschupp commented 1 year ago

--link c:\Strawberry\perl\vendor\lib\auto\DBD\mysql\mysql.xs.dll

This shouldn't be necessary. Could you verify that C:\Users\console\AppData\Local\Temp\2\par-636f6e736f6c65\cache-ee29a3cd85eb611c8a00b9972a27e709b24ef593\bc4e1068.xs.dll is actually a copy of c:\Strawberry\perl\vendor\lib\auto\DBD\mysql\mysql.xs.dll (e.g. compare md5sum's)?

My guess is that mysql.xs.dll (which is the "glue" DLL from DBD::mysql) is linked against the actual (C-level) mysql client library. To check:

objdump -ax ...\mysql.xs.dll

and look for "DLL Name: ...." lines. Any DLL that isn't a Windows system DLL (like e.g. kernel32.dll) should be added with --link to your pp command line. Note that you may have to repeat this check for any DLL found (the mysql client library is probably linked against libz and libs from OpenSSL). Or you could use the following (from the build directory of PAR::Packer):

perl -MData::Dumper -E "require 'myldr/find_files_to_embed/recursive_objdump.pl'; say Dumper(recursive_objdump($ARGV[0]));"  ...\mysql.xs.dll
shawnlaffan commented 1 year ago

@bitjet - pp_autolink was developed for this issue. https://metacpan.org/pod/App::PP::Autolink

When I run that on a simplified script (below) it detects DLLs for libcrypto, libpq, libssl, zlib and libmysql. I did not use the -x flag so there might be more DLLs if additional libs are loaded when your script is run.

use strict;
use warnings;
use DBI;
print 1;