DBD-mysql
DBD-mysql copied to clipboard
macOS: Library not loaded: @rpath/libmysqlclient.21.dylib
I am trying to install on macOS 12.0.1 Monterey, Apple M1 chip. First I downloaded community version 8.0.26 of MySQL from https://dev.mysql.com/downloads/mysql/
After installing by running the downloaded .dmg file, and patching mysql_config as described here (see also issue #322) , I have:
$ mysql_config --help
Usage: /usr/local/mysql-8.0.26-macos11-arm64/bin/mysql_config [OPTIONS]
Compiler: AppleClang 12.0.0.12000032
Options:
--cflags [-I/usr/local/mysql-8.0.26-macos11-arm64/include ]
--cxxflags [-I/usr/local/mysql-8.0.26-macos11-arm64/include ]
--include [-I/usr/local/mysql-8.0.26-macos11-arm64/include]
--libs [-L/usr/local/mysql-8.0.26-macos11-arm64/lib -lmysqlclient]
--libs_r [-L/usr/local/mysql-8.0.26-macos11-arm64/lib -lmysqlclient]
--plugindir [/usr/local/mysql-8.0.26-macos11-arm64/lib/plugin]
--socket [/tmp/mysql.sock]
--port [0]
--version [8.0.26]
--variable=VAR VAR is one of:
pkgincludedir [/usr/local/mysql-8.0.26-macos11-arm64/include]
pkglibdir [/usr/local/mysql-8.0.26-macos11-arm64/lib]
plugindir [/usr/local/mysql-8.0.26-macos11-arm64/lib/plugin]
If I now run Makefile.PL :
perl Makefile.PL
I will use the following settings for compiling and testing:
cflags (mysql_config ) = -I/usr/local/mysql-8.0.26-macos11-arm64/include
embedded (guessed ) =
ldflags (guessed ) =
libs (mysql_config ) = -L/usr/local/mysql-8.0.26-macos11-arm64/lib -lmysqlclient
mysql_config (Users choice ) = mysql_config
nocatchstderr (default ) = 0
nofoundrows (default ) = 0
nossl (default ) = 0
testdb (User's choice) = test
testhost (User's choice) = localhost
testpassword (User's choice) = pass
testport (default ) =
testsocket (default ) =
testuser (User's choice) = testuser
To change these settings, see 'perl Makefile.PL --help' and
'perldoc DBD::mysql::INSTALL'.
Checking if libs are available for compiling...
dyld[29491]: Library not loaded: @rpath/libmysqlclient.21.dylib
Referenced from: /Users/hakonhaegland/perl/github/DBD-mysql/assertlibCDrvVKJG
Reason: tried: '/usr/local/lib/libmysqlclient.21.dylib' (no such file), '/usr/lib/libmysqlclient.21.dylib' (no such file)
wrong result: 'mysqlclient'
I added a PR for Devel::CheckLib that fixes this issue: https://github.com/mattn/p5-Devel-CheckLib/pull/35
Could you check if this issue is also in DBD::MariaDB? It has also checks for mysql client library via Devel::CheckLib.
Could you check if this issue is also in DBD::MariaDB?
@pali Thanks for the suggestion. This was interesting, I installed MariaDB first using Homebrew:
$ brew install mariadb
$ brew services start mariadb
==> Successfully started `mariadb` (label: homebrew.mxcl.mariadb)
Then tried to install DBD::MariaDB (Using the current version of Devel::CheckLib):
$ git clone [email protected]:gooddata/DBD-MariaDB.git
$ cd DBD-MariaDB
$ perl Makefile.PL
PLEASE NOTE:
For 'make test' to run properly, you must ensure that the
database user 'hakonhaegland' can connect to your MariaDB or MySQL server
and has the proper privileges that these tests require such
as 'drop table', 'create table', 'drop procedure', 'create procedure'
as well as others.
mysql> grant all privileges on test.* to 'hakonhaegland'@'localhost' identified by 's3kr1t';
You can also optionally set the user to run 'make test' with:
perl Makefile.PL --testuser=username
I will use the following settings for compiling and testing:
cflags (mysql_config) = -I/opt/homebrew/Cellar/mariadb/10.6.4/include/mysql -I/opt/homebrew/Cellar/mariadb/10.6.4/include/mysql/mysql
libs (mysql_config) = -L/opt/homebrew/Cellar/mariadb/10.6.4/lib/ -lmariadb
mysql_config (guessed ) = mariadb_config
testdb (default ) = test
testhost (default ) =
testpassword (default ) =
testport (default ) =
testsocket (default ) =
testuser (guessed ) = hakonhaegland
To change these settings, see 'perl Makefile.PL --help' and
'perldoc DBD::MariaDB::INSTALL'.
Checking if libs and header files are available for compiling...
Checking if correct version of MariaDB or MySQL client is present...
Looks good.
Embedded server: not supported by client library
Client library deinitialize OpenSSL library functions: no
WARNING: Older versions of ExtUtils::MakeMaker may errantly install README.pod as part of this distribution. It is recommended to avoid using this path in CPAN modules.
Using DBI 1.643 (for perl 5.034000 on darwin-2level) installed in /Users/hakonhaegland/perl5/perlbrew/perls/perl-5.34.0/lib/site_perl/5.34.0/darwin-2level/auto/DBI/
Generating a Unix-style Makefile
Writing Makefile for DBD::MariaDB
Writing MYMETA.yml and MYMETA.json
So it works fine without the patch in https://github.com/mattn/p5-Devel-CheckLib/pull/35. I investigated this a bit further and found that the reason was that libmariadb.dylib has an absolute install name (whereas libmysqlclient.dylib had an install name relative to @rpath):
$ mariadb_config --help
Copyright 2011-2020 MariaDB Corporation AB
Get compiler flags for using the MariaDB Connector/C.
Usage: mariadb_config [OPTIONS]
Compiler: Clang 13.0.0.13000029
--cflags [-I/opt/homebrew/Cellar/mariadb/10.6.4/include/mysql -I/opt/homebrew/Cellar/mariadb/10.6.4/include/mysql/mysql]
--include [-I/opt/homebrew/Cellar/mariadb/10.6.4/include/mysql -I/opt/homebrew/Cellar/mariadb/10.6.4/include/mysql/mysql]
--libs [-L/opt/homebrew/Cellar/mariadb/10.6.4/lib/ -lmariadb]
--libs_r [-L/opt/homebrew/Cellar/mariadb/10.6.4/lib/ -lmariadb]
--libs_sys [-lssl -lcrypto]
--version [10.6.4]
--cc_version [3.2.4]
--socket [/tmp/mysql.sock]
--port [3306]
--plugindir [/opt/homebrew/Cellar/mariadb/10.6.4/lib/plugin]
--tlsinfo [OpenSSL 1.1.1l]
--variable=VAR VAR is one of:
pkgincludedir [/opt/homebrew/Cellar/mariadb/10.6.4/include/mysql]
pkglibdir [/opt/homebrew/Cellar/mariadb/10.6.4/lib]
pkgplugindir [/opt/homebrew/Cellar/mariadb/10.6.4/lib/plugin]
$ otool -D /opt/homebrew/Cellar/mariadb/10.6.4/lib/libmariadb.dylib
/opt/homebrew/Cellar/mariadb/10.6.4/lib/libmariadb.dylib:
/opt/homebrew/opt/mariadb/lib/libmariadb.3.dylib
Whereas for libmysqlclient.dylib :
$ otool -D /usr/local/mysql-8.0.26-macos11-arm64/lib/libmysqlclient.dylib
/usr/local/mysql-8.0.26-macos11-arm64/lib/libmysqlclient.dylib:
@rpath/libmysqlclient.21.dylib
So I guess the -Wl,-rpath patch https://github.com/mattn/p5-Devel-CheckLib/pull/35 is only needed when the library has an @rpath relative install name.
You could also try to compile DBD::MariaDB with the same mysql client library which is causing issue in this ticket.
@pali Yes, that does fail as expected:
$ perl Makefile.PL --mysql_config=/usr/local/mysql-8.0.26-macos11-arm64/bin/mysql_config
dyld[27062]: Library not loaded: @rpath/libmysqlclient.21.dylib
Referenced from: /Users/hakonhaegland/perl/github/DBD-MariaDB/assertlib5wHTAXgl
Reason: tried: '/usr/local/lib/libmysqlclient.21.dylib' (no such file), '/usr/lib/libmysqlclient.21.dylib' (no such file)
dyld[27080]: Library not loaded: @rpath/libmysqlclient.21.dylib
Referenced from: /Users/hakonhaegland/perl/github/DBD-MariaDB/assertlib62AXQb9G
Reason: tried: '/usr/local/lib/libmysqlclient.21.dylib' (no such file), '/usr/lib/libmysqlclient.21.dylib' (no such file)
dyld[27105]: Library not loaded: @rpath/libmysqlclient.21.dylib
Referenced from: /Users/hakonhaegland/perl/github/DBD-MariaDB/assertlibU3ZR3JwQ
Reason: tried: '/usr/local/lib/libmysqlclient.21.dylib' (no such file), '/usr/lib/libmysqlclient.21.dylib' (no such file)
dyld[27118]: Library not loaded: @rpath/libmysqlclient.21.dylib
Referenced from: /Users/hakonhaegland/perl/github/DBD-MariaDB/assertlib_DmKKHde
Reason: tried: '/usr/local/lib/libmysqlclient.21.dylib' (no such file), '/usr/lib/libmysqlclient.21.dylib' (no such file)
I will use the following settings for compiling and testing:
cflags (mysql_config ) = -I/usr/local/mysql-8.0.26-macos11-arm64/include
libs (mysql_config ) = -L/usr/local/mysql-8.0.26-macos11-arm64/lib -lmysqlclient
mysql_config (User's choice) = /usr/local/mysql-8.0.26-macos11-arm64/bin/mysql_config
testdb (User's choice) = test
testhost (default ) =
testpassword (User's choice) =
testport (default ) =
testsocket (default ) =
testuser (User's choice) = hakonhaegland
To change these settings, see 'perl Makefile.PL --help' and
'perldoc DBD::MariaDB::INSTALL'.
Checking if libs and header files are available for compiling...
Checking if correct version of MariaDB or MySQL client is present...
dyld[27131]: Library not loaded: @rpath/libmysqlclient.21.dylib
Referenced from: /Users/hakonhaegland/perl/github/DBD-MariaDB/assertlibpiPO_y3D
Reason: tried: '/usr/local/lib/libmysqlclient.21.dylib' (no such file), '/usr/lib/libmysqlclient.21.dylib' (no such file)
ERROR: Wrong version or unable to check version of MariaDB/MySQL include files.
To build DBD::MariaDB it is needed MariaDB or MySQL client >= 4.1.8.
Ok, thank you for testing! Now we know that it needs to be properly fixed in MakeMaker, CheckLib, etc...
@pali You are welcome, btw it has just been fixed in ExtUtils::MakeMaker via https://github.com/Perl-Toolchain-Gang/ExtUtils-MakeMaker/pull/403