Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error installing DBD::MySQL on osx 10.11 - Can't link/include C library '', aborting

After updating perl via homebrew, i broke my dbd::mysql installation installing via cpanm results in:

I will use the following settings for compiling and testing:

    cflags        (mysql_config) = -I/usr/local/Cellar/mysql-connector-
    c/6.1.9/include
    embedded      (guessed     ) =
    ldflags       (guessed     ) =
    libs          (mysql_config) = -L/usr/local/Cellar/mysql-connector-
    c/6.1.9/lib -l
    mysql_config  (guessed     ) = mysql_config
    nocatchstderr (default     ) = 0
    nofoundrows   (default     ) = 0
    nossl         (default     ) = 0
    testdb        (default     ) = test
    testhost      (default     ) =
    testpassword  (default     ) =
    testport      (default     ) =
    testsocket    (default     ) =
    testuser      (guessed     ) = root

To change these settings, see 'perl Makefile.PL --help' and 'perldoc DBD::mysql::INSTALL'.

Checking if libs are available for compiling...
Can't link/include C library '', aborting.

Does anyone know how to resolve? I've tried removing mysql-connector-c and installing mysql via homebrew instead. The complaint then is Can't link/include C library 'ssl', 'crypto', aborting. I do have openssl installed.

perl version:

This is perl 5, version 24, subversion 1 (v5.24.1) built for
darwin-thread-multi-2level
like image 309
dion Avatar asked Apr 25 '17 22:04

dion


3 Answers

I followed the link given in @Benny K answer as the commands he gave didn't worked for me and simply executed the below command and it worked

cpanm DBD::mysql --configure-args="--libs='-L/usr/local/opt/openssl/lib -lssl -lcrypto -L/usr/local/lib -lmysqlclient'"
like image 182
Ram Avatar answered Oct 23 '22 20:10

Ram


This is an old question, but I just had this problem installing DBD::mysql and I see that others are still having this problem too. Here's the convoluted solution that worked for me.

I started by running (MacOX Mojave 10.14.1):

  • brew install mysql
  • cpanm install DBD::mysql
  • This fails.

This gave me the error message "Can't link/include C library 'ssl', 'crypto', aborting". As per this thread and the DBD::mysql install instructions on meta-cpan, this error is happening because the DBD::mysql package requires (?) "mysql-connector-c" rather than "mysql". Okay, I fixed that by doing:

  • brew unlink mysql
  • brew install mysql-connector-c
  • cpanm install DBD::mysql
  • The cpan install still fails, but new error!

That "fixed" the issue in that it got me a different error message. I was now getting the message: "Can't link/include C library'', aborting". Progress! Now I was getting the error on this answer. I fixed this error by:

  • Verifying that my problem is indeed from missing linkage flags.
  • Run mysql_config
  • This returns something like: --libs [L/usr/local/Cellar/mysql-connector-c/6.1.11/lib -l]
  • Note that the "-l" at the end has nothing after it, which is incorrect.
  • Edit /usr/local/Cellar/mysql-connector-c/6.1.11/bin/mysql_config line #114
  • Change libs="$libs -l" to libs="$libs -lmysqlclient"
  • Verify that it worked: mysql_config
  • This should return something like: --libs [L/usr/local/Cellar/mysql-connector-c/6.1.11/lib -lmysqlclient]
  • Again do cpanm install DBD::mysql
  • This time it works!!!
  • Be wary: We're not installing the lib for SSL connections which will probably cause cryptic problems later.

This got DBD::mysql installed successfully for me. I do think I'm going to have to go back and add some more linkage flags.

like image 15
charley Avatar answered Oct 23 '22 22:10

charley


  1. show mysql_config path by which mysql_config

    eg: /usr/local/opt/[email protected]/bin/mysql_config

  2. show openssl lib path by which openssl. note: if it's a symbol in /usr/local/bin/openssl, you can type ls -ld /usr/local/bin/openssl to show real path

    eg: if it's /usr/local/openssl/bin/openssl, then you can insert -L/usr/local/openssl/lib/ for searching crypto and ssl libs

  3. edit mysql_config file and insert path of openssl lib(line #114)

    eg: libs=$libs -L/usr/local/opt/openssl/lib

    insert path of openssl lib 4.type cpan install DBD::mysql , success.

like image 14
Homqyy Avatar answered Oct 23 '22 20:10

Homqyy