Perl statically compiled DBD

Source: Internet
Author: User
Tags rpmbuild

Compiling DBD

Perl is often used in projects, but Perl needs to rely on the DBI,DBD driver when connecting to the database, but it relies on the Lib library of the database when installing DBD drivers by default.

For example, Perl is connected to MySQL and needs to install MySQL client.

Using static compilation, the Libclient Library of DBI, DBD, and MySQL client are compiled statically. In this way, distributed to the machine, it can be used.

    1. Compiling Perl, DBI

This step is not dependent, download the latest perl,dbi, follow the Make&&make install to the/home/myperl directory.

2. Install MySQL

    Compile the latest MySQL, here only need to statically compile libclient.a on it, do not need so file.

3. Statically compiled DBD

    Compile using perl from/home/myperl


This compiled/home/myperl is statically compiled DBD version, directly distributed to the target machine to use on it.

You can use the LDD file to view dependencies.

When used, the PL script interpreter points to the #!/home/myperl/bin/perl

RPM Packaging


Because the environment needs RPM package to use, try to write a simple Makefile,spec file, with Rpmbuild to hit a RPM package.


    1. Prepare makefile:
-o test test.otest.o:test.c        -C Test.cclean:          -RF TEST.O testinstall:        -D ${ destdir}/${prefix_perl}        -D ${destdir}/${prefix_ms        }755 Test ${destdir}/ ${prefix_ms}         -R bin/${destdir}/${prefix_perl         }-R lib/${destdir}/${prefix_perl}        -R man/${ Destdir}/${prefix_perl}

2. Prepare the Spec file


name:myperlversion:1.0.0Release:% (echo $RELEASE)%{?Dist} License:GPLGroup:ApplicationBuildRoot:%{_tmppath}/%{name}-%{version}-%{release}-Rootautoreqprov:no: Remove all dependent checks and provide Summary:myperl%Description%Prep%BUILDCD $OLDPWD/.. / Make%INSTALLCD $OLDPWD/.. /Make install DESTDIR= $RPM _build_root prefix=/home/Myperl%CLEANRM-RF $RPM _build_root%Files%defattr (-,root,root,-)/home/myperl/*%changelog

3. Build RPM Package


Rpmbuild Myperl.spec

The myperl-1.0.0-1.el6.x86_64.rpm is called, so it can be used directly, not relying on any Lib library.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.