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.
- 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
/home/myperl/bin/perl makefile.pl--mysql_config=/usr/local/bin/mysql_config
This compiled/home/myperl is statically compiled DBD version, directly distributed to the target machine to use on it.
You can use the LDD mysql.so 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.
Steps:
- 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.