perl5-dbi / DBD-MariaDB

Perl MariaDB driver

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot build with CentOS 7

oraclejavanet opened this issue · comments

Hello,

I am having a very difficult time trying to build this module (PALI/DBD-MariaDB-1.21.tar.gz) on CentOS 7. I'm uncertain how much information I should supply. I'm hoping it will be enough.

  1. Install CentOS 7 (minimal install)

  2. Install CPAN

    sudo yum -y install gcc perl-CPAN
    
  3. Install Linux dependencies

    sudo yum install -y perl-devel
    sudo yum install -y gcc
    sudo yum install -y gcc-c++
    sudo yum install -y glibc
    sudo yum install -y glibc.i686
    sudo yum install -y glibc-devel
    sudo yum install -y glibc-devel.i686
    sudo yum install -y openssl-devel
    sudo yum install -y bzip2 bzip2-devel
    
  4. Install MariaDB development libraries. Add the MariaDB yum repository by creating the file /etc/yum.repos.d/mariadb.repo:

    [mariadb]
    name = MariaDB
    baseurl = http://yum.mariadb.org/10.4/rhel7-amd64
    gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
    gpgcheck=1
    

    Add the repository:

    sudo yum clean all
    sudo yum install -y mariadb-devel mariadb-libs
    
  5. Check the MariaDB configuration:

    # mariadb_config
    Copyright 2011-2019 MariaDB Corporation AB
    Get compiler flags for using the MariaDB Connector/C.
    Usage: mariadb_config [OPTIONS]
      --cflags        [-I/usr/include/mysql -I/usr/include/mysql/mysql]
      --include       [-I/usr/include/mysql -I/usr/include/mysql/mysql]
      --libs          [-L/usr/lib64/ -lmariadb]
      --libs_r        [-L/usr/lib64/ -lmariadb]
      --libs_sys      [-lz -ldl -lm -lpthread -lssl -lcrypto]
      --version       [10.4.8]
      --cc_version    [3.1.4]
      --socket        [/var/lib/mysql/mysql.sock]
      --port          [3306]
      --plugindir     [/usr/lib64/mysql/plugin]
      --tlsinfo       [OpenSSL 1.0.2k]
    
  6. Here is the first issue I ran in to. Installing DBD::MariaDB uses the command mariadb_config to set header files and library files (see above). One of the MariaDB library files libmariadb.a is incorrectly named libmariadbd.a. I resolved this by creating the following symbolic link:

    ln -s /usr/lib64/libmariadbd.a /usr/lib64/libmariadb.a
    
  7. Install DBI - the database independent interface for Perl:

    cpan[1]> install DBI
    
  8. Install DBD::MariaDB:

    export DBD_MARIADB_TESTDB=mysql
    export DBD_MARIADB_TESTHOST=alamode-db
    export DBD_MARIADB_TESTPORT=3306
    export DBD_MARIADB_TESTUSER=dbadmin
    export DBD_MARIADB_TESTPASSWORD=manager
    
    cpan[1]> install DBD::MariaDB
    
  9. And now the error:

    Reading '/root/.cpan/Metadata'
      Database was generated on Tue, 15 Oct 2019 20:41:03 GMT
    Running install for module 'DBD::MariaDB'
    Checksum for /root/.cpan/sources/authors/id/P/PA/PALI/DBD-MariaDB-1.21.tar.gz ok
    Scanning cache /root/.cpan/build for sizes
    ...................................................-------------------------DONE
    DEL(1/6): /root/.cpan/build/DBI-1.642-0
    DEL(2/6): /root/.cpan/build/DBI-1.642-0.yml
    DEL(3/6): /root/.cpan/build/Mock-Config-0.03-0
    DEL(4/6): /root/.cpan/build/Mock-Config-0.03-0.yml
    DEL(5/6): /root/.cpan/build/Devel-CheckLib-1.13-0.yml
    DEL(6/6): /root/.cpan/build/Devel-CheckLib-1.13-0
    Configuring P/PA/PALI/DBD-MariaDB-1.21.tar.gz with Makefile.PL
    I will use the following settings for compiling and testing:
    
      cflags       (mysql_config) = -I/usr/include/mysql -I/usr/include/mysql/mysql
      libs         (mysql_config) = -L/usr/lib64/ -lmariadb
      mysql_config (guessed     ) = mariadb_config
      testdb       (environment ) = mysql
      testhost     (environment ) = alamode-db
      testpassword (environment ) = image
      testport     (environment ) = 3306
      testsocket   (default     ) =
      testuser     (environment ) = dbadmin
    
    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: yes
    
    Checking if your kit is complete...
    Looks good
    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.642 (for perl 5.016003 on x86_64-linux-thread-multi) installed in /usr/local/lib64/perl5/auto/DBI/
    Generating a Unix-style Makefile
    Writing Makefile for DBD::MariaDB
    Writing MYMETA.yml and MYMETA.json
      PALI/DBD-MariaDB-1.21.tar.gz
      /usr/bin/perl Makefile.PL -- OK
    Running make for P/PA/PALI/DBD-MariaDB-1.21.tar.gz
    cp lib/DBD/MariaDB.pod blib/lib/DBD/MariaDB.pod
    cp lib/DBD/MariaDB.pm blib/lib/DBD/MariaDB.pm
    cp lib/DBD/MariaDB/INSTALL.pod blib/lib/DBD/MariaDB/INSTALL.pod
    Running Mkbootstrap for MariaDB ()
    chmod 644 "MariaDB.bs"
    "/usr/bin/perl" -MExtUtils::Command::MM -e 'cp_nonempty' -- MariaDB.bs blib/arch/auto/DBD/MariaDB/MariaDB.bs 644
    "/usr/bin/perl" -p -e "s/~DRIVER~/MariaDB/g" /usr/local/lib64/perl5/auto/DBI/Driver.xst > MariaDB.xsi
    "/usr/bin/perl" "/usr/share/perl5/vendor_perl/ExtUtils/xsubpp"  -typemap '/usr/share/perl5/ExtUtils/typemap'  MariaDB.xs > MariaDB.xsc
    Warning: duplicate function definition 'do' detected in MariaDB.xs, line 104
    Warning: duplicate function definition 'rows' detected in MariaDB.xs, line 229
    Warning: duplicate function definition 'last_insert_id' detected in MariaDB.xs, line 248
    mv MariaDB.xsc MariaDB.c
    gcc -c  -I/usr/local/lib64/perl5/auto/DBI -I/usr/include/mysql -I/usr/include/mysql/mysql -DHAVE_DBI_1_634 -DHAVE_DBI_1_642 -DHAVE_PROBLEM_WITH_OPENSSL -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic   -DVERSION=\"1.21\" -DXS_VERSION=\"1.21\" -fPIC "-I/usr/lib64/perl5/CORE"   MariaDB.c
    gcc -c  -I/usr/local/lib64/perl5/auto/DBI -I/usr/include/mysql -I/usr/include/mysql/mysql -DHAVE_DBI_1_634 -DHAVE_DBI_1_642 -DHAVE_PROBLEM_WITH_OPENSSL -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic   -DVERSION=\"1.21\" -DXS_VERSION=\"1.21\" -fPIC "-I/usr/lib64/perl5/CORE"   dbdimp.c
    gcc -c  -I/usr/local/lib64/perl5/auto/DBI -I/usr/include/mysql -I/usr/include/mysql/mysql -DHAVE_DBI_1_634 -DHAVE_DBI_1_642 -DHAVE_PROBLEM_WITH_OPENSSL -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic   -DVERSION=\"1.21\" -DXS_VERSION=\"1.21\" -fPIC "-I/usr/lib64/perl5/CORE"   socket.c
    rm -f blib/arch/auto/DBD/MariaDB/MariaDB.so
    gcc  -shared -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -Wl,-z,relro   MariaDB.o dbdimp.o socket.o  -o blib/arch/auto/DBD/MariaDB/MariaDB.so  \
       -L/usr/lib64/ -lmariadb   \
    
    chmod 755 blib/arch/auto/DBD/MariaDB/MariaDB.so
    Manifying 2 pod documents
      PALI/DBD-MariaDB-1.21.tar.gz
      /usr/bin/make -- OK
    Running make test for PALI/DBD-MariaDB-1.21.tar.gz
    "/usr/bin/perl" -MExtUtils::Command::MM -e 'cp_nonempty' -- MariaDB.bs blib/arch/auto/DBD/MariaDB/MariaDB.bs 644
    PERL_DL_NONLAZY=1 "/usr/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
    t/00base.t .............................. 1/7 Bailout called.  Further testing stopped:  Unable to load DBD::MariaDB: Can't load '/root/.cpan/build/DBD-MariaDB-1.21-5/blib/arch/auto/DBD/MariaDB/MariaDB.so' for module DBD::MariaDB: /root/.cpan/build/DBD-MariaDB-1.21-5/blib/arch/auto/DBD/MariaDB/MariaDB.so: undefined symbol: _ZTVN10__cxxabiv117__class_type_infoE at /usr/lib64/perl5/DynaLoader.pm line 190.  at t/00base.t line 18. Compilation failed in require at t/00base.t line 18. BEGIN failed--compilation aborted at t/00base.t line 18.
    FAILED--Further testing stopped: Unable to load DBD::MariaDB: Can't load '/root/.cpan/build/DBD-MariaDB-1.21-5/blib/arch/auto/DBD/MariaDB/MariaDB.so' for module DBD::MariaDB: /root/.cpan/build/DBD-MariaDB-1.21-5/blib/arch/auto/DBD/MariaDB/MariaDB.so: undefined symbol: _ZTVN10__cxxabiv117__class_type_infoE at /usr/lib64/perl5/DynaLoader.pm line 190.  at t/00base.t line 18. Compilation failed in require at t/00base.t line 18. BEGIN failed--compilation aborted at t/00base.t line 18.
    make: *** [test_dynamic] Error 255
    Lockfile removed.
      PALI/DBD-MariaDB-1.21.tar.gz
      /usr/bin/make test -- NOT OK
    //hint// to see the cpan-testers results for installing this module, try:
      reports PALI/DBD-MariaDB-1.21.tar.gz
    Failed during this command:
     PALI/DBD-MariaDB-1.21.tar.gz                 : make_test NO
    

Hello,

I performed some additional testing and it appears the problem is with the version of MariaDB development libraries I am using from the MariaDB yum repository. The first hint should have been the symbolic link I needed to create (ln -s /usr/lib64/libmariadbd.a /usr/lib64/libmariadb.a).

I tried MariaDB version 10.4 and 10.3 from the MariaDB yum repository, both of them failed as shown in my original post.

I finally completed removed the MariaDB yum repository from the system and installed the MariaDB libraries that came with the CentoOS 7 distribution (version 5.5). This worked.

  1. Remove MariaDB yum repository:

    # rpm -e MariaDB-compat MariaDB-common MariaDB-devel
    # rm -f /etc/yum.repos.d/mariadb.repo
    # yum clean all
    
  2. Install the MariaDB development libraries from the CentOS 7 distribution:

    # yum install mariadb-devel mariadb-libs
    
      Installing : 1:mariadb-libs-5.5.64-1.el7.x86_64
      Installing : 1:mariadb-devel-5.5.64-1.el7.x86_64
    
  3. Check out the MariaDB config (notice that there is no mariadb_config command):

    # mysql_config
    Usage: /usr/bin/mysql_config [OPTIONS]
    Options:
            --cflags         [-I/usr/include/mysql]
            --include        [-I/usr/include/mysql]
            --libs           [-L/usr/lib64/mysql -lmysqlclient -lpthread -lz -lm -ldl -lssl -lcrypto]
            --libs_r         [-L/usr/lib64/mysql -lmysqlclient -lpthread -lz -lm -ldl -lssl -lcrypto]
            --plugindir      [/usr/lib64/mysql/plugin]
            --socket         [/var/lib/mysql/mysql.sock]
            --port           [0]
            --version        [5.5.64]
            --libmysqld-libs [-L/usr/lib64/mysql -lmysqld]
            --variable=VAR   VAR is one of:
                    pkgincludedir [/usr/include/mysql]
                    pkglibdir     [/usr/lib64/mysql]
                    plugindir     [/usr/lib64/mysql/plugin]
    
  4. Install DBD::MariaDB module (successful):

    cpan[1]> install DBD::MariaDB
    
    ...
    
    All tests successful.
    Files=90, Tests=7,  8 wallclock secs ( 0.20 usr  0.07 sys +  6.48 cusr  1.22 csys =  7.97 CPU)
    Result: PASS
    Lockfile removed.
      PALI/DBD-MariaDB-1.21.tar.gz
      /usr/bin/make test -- OK
    Running make install for PALI/DBD-MariaDB-1.21.tar.gz
    "/usr/bin/perl" -MExtUtils::Command::MM -e 'cp_nonempty' -- MariaDB.bs blib/arch/auto/DBD/MariaDB/MariaDB.bs 644
    Manifying 2 pod documents
    Files found in blib/arch: installing files in blib/lib into architecture dependent library tree
    Installing /usr/local/lib64/perl5/auto/DBD/MariaDB/MariaDB.so
    Installing /usr/local/lib64/perl5/DBD/MariaDB.pod
    Installing /usr/local/lib64/perl5/DBD/MariaDB.pm
    Installing /usr/local/lib64/perl5/DBD/MariaDB/INSTALL.pod
    Installing /usr/local/share/man/man3/DBD::MariaDB.3pm
    Installing /usr/local/share/man/man3/DBD::MariaDB::INSTALL.3pm
    Appending installation info to /usr/lib64/perl5/perllocal.pod
      PALI/DBD-MariaDB-1.21.tar.gz
      sudo /usr/bin/make install  -- OK
    

So as you can see, there is a big difference between the MySQL and MariaDB versions. Is this expected behavior? Will there be an update that works with the versions of MariaDB obtained from their official MariaDB yum repository?

Thanks in advanced,
~jeff

commented

Hello!

  1. Here is the first issue I ran in to. Installing DBD::MariaDB uses the command mariadb_config to set header files and library files (see above). One of the MariaDB library files libmariadb.a is incorrectly named libmariadbd.a. I resolved this by creating the following symbolic link:

    ln -s /usr/lib64/libmariadbd.a /usr/lib64/libmariadb.a
    

Please do not do that ...

   t/00base.t .............................. 1/7 Bailout called.  Further testing stopped:  Unable to load DBD::MariaDB: Can't load '/root/.cpan/build/DBD-MariaDB-1.21-5/blib/arch/auto/DBD/MariaDB/MariaDB.so' for module DBD::MariaDB: /root/.cpan/build/DBD-MariaDB-1.21-5/blib/arch/auto/DBD/MariaDB/MariaDB.so: undefined symbol: _ZTVN10__cxxabiv117__class_type_infoE at /usr/lib64/perl5/DynaLoader.pm line 190.  at t/00base.t line 18. Compilation failed in require at t/00base.t line 18. BEGIN failed--compilation aborted at t/00base.t line 18.
   FAILED--Further testing stopped: Unable to load DBD::MariaDB: Can't load '/root/.cpan/build/DBD-MariaDB-1.21-5/blib/arch/auto/DBD/MariaDB/MariaDB.so' for module DBD::MariaDB: /root/.cpan/build/DBD-MariaDB-1.21-5/blib/arch/auto/DBD/MariaDB/MariaDB.so: undefined symbol: _ZTVN10__cxxabiv117__class_type_infoE at /usr/lib64/perl5/DynaLoader.pm line 190.  at t/00base.t line 18. Compilation failed in require at t/00base.t line 18. BEGIN failed--compilation aborted at t/00base.t line 18.

... as this error would be expected.

Library libmariadbd.a contains client with embedded server and library libmariadb.a contains only client. Building version with embedded server requires different compile flags and Makefile.PL in DBD::MariaDB already handles them. But if you create such symlink then you confuse both Makefile.PL and gcc which would just lead to incorrectly compiled DBD::MariaDB module and so DBD::MariaDB would not work. Above runtime undefined symbol errors related to C++ virtual tables is then expected.

Can you please to build it again without that symbolic link?

Also what is the output of commands mysql_config --libmysqld-libs and mariadb_config --libmysqld-libs?

Hello,

Thank you for the quick reply and the detailed information on libmariadbd.a versus libmariadb.a. I will walk through the install again from the start with the MariaDB 10.4 client / CPAN DBD::MariaDB and provide the output from mysql_config --libmysqld-libs and mariadb_config --libmysqld-libs.

~jeff

commented

Hello, have you tried it to build without that problematic symlink?

Hello. Sorry for the delay. I resolved the issue. I needed to install the MariaDB Client Library.

sudo yum install -y MariaDB-devel MariaDB-shared

The dynamic client libraries found in the MariaDB-shared Linux package are required to compile the RMariaDB package. Failing to install the dynamic client libraries will result in an error when attempting to compile the RMariaDB package.

I did not find this mentioned anywhere in the RMariaDB install instructions.

Thanks for checking back.
~jeff

commented

Ok, so problem is solved. I will close this issue.