The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

C Compiler flags</pre> <p>It is typically not so difficult to determine the appropriate flags for the C compiler. The linker flags, which you find in the next section, are another story.</p> <p>The determination of the C compiler flags is usually left to a configuration script called <em>mysql_config</em>, which can be invoked with</p> <pre> mysql_config --cflags</pre> <p>When doing so, it will emit a line with suggested C compiler flags, for example like this:</p> <pre> -L/usr/include/mysql</pre> <p>The C compiler must find some header files. Header files have the extension <code>.h</code>. MySQL header files are, for example, <em>mysql.h</em> and <em>mysql_version.h</em>. In most cases the header files are not installed by default. For example, on Windows it is an installation option of the MySQL setup program (Custom installation), whether the header files are installed or not. On Red Hat Linux, you need to install an RPM archive <em>mysql-devel</em> or <em>MySQL-devel</em>.</p> <p>If you know the location of the header files, then you will need to add an option</p> <pre> -L&lt;header directory&gt;</pre> <p>to the C compiler flags, for example <code>-L/usr/include/mysql</code>.</p> <p> </p> <h2><a name="linker_flags">Linker flags</a></h2> <p>Appropriate linker flags are the most common source of problems while installing DBD::mysql. I will only give a rough overview, you'll find more details in the troubleshooting section. <a href="#known_problems">KNOWN PROBLEM/a</p> <p>The determination of the C compiler flags is usually left to a configuration script called <em>mysql_config</em>, which can be invoked with</p> <pre> mysql_config --libs</pre> <p>When doing so, it will emit a line with suggested C compiler flags, for example like this:</p> <pre> -L'/usr/lib/mysql' -lmysqlclient -lnsl -lm -lz -lcrypt</pre> <p>The following items typically need to be configured for the linker:</p> <dl> <dt><strong><a name="item_the_mysqlclient_library">The mysqlclient library</a></strong><br /> </dt> <dd> The MySQL client library comes as part of the MySQL distribution. Depending on your system it may be a file called </dd> <dd> <pre> F&lt;libmysqlclient.a&gt; statically linked library, Unix F&lt;libmysqlclient.so&gt; dynamically linked library, Unix F&lt;mysqlclient.lib&gt; statically linked library, Windows F&lt;mysqlclient.dll&gt; dynamically linked library, Windows</pre> </dd> <dd> <p>or something similar.</p> </dd> <dd> <p>As in the case of the header files, the client library is typically not installed by default. On Windows you will need to select them while running the MySQL setup program (Custom installation). On Red Hat Linux an RPM archive <em>mysql-devel</em> or <em>MySQL-devel</em> must be installed.</p> </dd> <dd> <p>The linker needs to know the location and name of the mysqlclient library. This can be done by adding the flags</p> </dd> <dd> <pre> -L&lt;lib directory&gt; -lmysqlclient</pre> </dd> <dd> <p>or by adding the complete path name. Examples:</p> </dd> <dd> <pre> -L/usr/lib/mysql -lmysqlclient -LC:\mysql\lib -lmysqlclient</pre> </dd> <dd> <p>If you would like to use the static libraries (and there are excellent reasons to do so), you need to create a separate directory, copy the static libraries to that place and use the -L switch above to point to your new directory. For example:</p> </dd> <dd> <pre> mkdir /tmp/mysql-static cp /usr/lib/mysql/*.a /tmp/mysql-static perl Makefile.PL --libs=&quot;-L/tmp/mysql-static -lmysqlclient&quot; make make test make install rm -rf /tmp/mysql-static</pre> </dd> <p></p> <dt><strong><a name="item_the_gzip_library">The gzip library</a></strong><br /> </dt> <dd> The MySQL client can use compression when talking to the MySQL server, a nice feature when sending or receiving large texts over a slow network. </dd> <dd> <p>On Unix you typically find the appropriate file name by running</p> </dd> <dd> <pre> ldconfig -p | grep libz ldconfig -p | grep libgz</pre> </dd> <dd> <p>Once you know the name (libz.a or libgz.a is best), just add it to the list of linker flags. If this seems to be causing problem you may also try to link without gzip libraries.</p> </dd> <p></p></dl> <p> </p> <hr /> <h1><a name="special_systems">SPECIAL SYSTEM/a</h1> <p>Below you find information on particular systems:</p> <p> </p> <h2><a name="windows_cygwin">Windows/CygWin</a></h2> <p>If you are a user of Cygwin (the Redhat distribution) you already know, it contains a nicely running perl 5.6.1, installation of additional modules usually works as a charme via the standard procedure of</p> <pre> perl makefile.PL make make test make install</pre> <p>The Windows binary distribution of MySQL runs smoothly under Cygwin. You can start/stop the server and use all Windows clients without problem. But to install DBD::mysql you have to take a little special action.</p> <p>Don't attempt to build DBD::mysql against either the MySQL Windows or Linux/Unix BINARY distributions: neither will work!</p> <p>You MUST compile the MySQL clients yourself under Cygwin, to get a 'libmysqlclient.a' compiled under Cygwin. Really! You'll only need that library and the header files, you don't need any other client parts. Continue to use the Windows binaries. And don't attempt (currently) to build the MySQL Server part, it is unneccessary, as MySQL AB does an excellent job to deliver optimized binaries for the mainstream operating systems, and it is told, that the server compiled under Cygwin is unstable.</p> <p>Install MySQL (if you havn't already)</p> <dl> <dt><strong><a name="item__2d">-</a></strong><br /> </dt> <dd> download the MySQL Windows Binaries from <a href="http://www.mysql.com/downloads/index.html">http://www.mysql.com/downloads/index.html</a> </dd> <p></p> <dt><strong>-</strong><br /> </dt> <dd> unzip mysql-&lt;version&gt;-win.zip into some temporary location </dd> <p></p> <dt><strong>-</strong><br /> </dt> <dd> start the setup.exe there and follow the instructions </dd> <p></p> <dt><strong>-</strong><br /> </dt> <dd> start the server </dd> <p></p> <dt><strong>-</strong><br /> </dt> <dd> alternatively download, install and start the server on a remote server, on what supported OS ever </dd> <p></p></dl> <p>Build MySQL clients under Cygwin:</p> <dl> <dt><strong>-</strong><br /> </dt> <dd> download the MySQL LINUX source from <a href="http://www.mysql.com/downloads/index.html">http://www.mysql.com/downloads/index.html</a> </dd> <p></p> <dt><strong>-</strong><br /> </dt> <dd> unpack mysql-&lt;version&gt;.tar.gz into some tmp location </dd> <p></p> <dt><strong>-</strong><br /> </dt> <dd> cd into the unpacked dir mysql-&lt;version&gt; </dd> <dd> <pre> ./configure --prefix=/usr/local/mysql --without-server</pre> </dd> <dd> <p>This prepares the Makefile with the installed Cygwin features. It takes some time, but should finish without error. The 'prefix', as given, installs the whole Cygwin/MySQL thingy into a location not normally in your PATH, so that you continue to use already installed Windows binaries. The --without-server parameter tells configure to only build the clients.</p> </dd> <p></p> <dt><strong>-</strong><br /> </dt> <dd> <pre> make</pre> </dd> <dd> <p>This builds all MySQL client parts ... be patient. It should finish finally without any error.</p> </dd> <dt><strong>-</strong><br /> </dt> <dd> <pre> make install</pre> </dd> <dd> <p>This installs the compiled client files under /usr/local/mysql/. Remember, you don't need anything except the library under /usr/local/mysql/lib and the headers under /usr/local/mysql/include!</p> </dd> <dd> <p>Essentially you are now done with this part. If you want, you may try your compiled binaries shortly; for that, do:</p> </dd> <dt><strong>-</strong><br /> </dt> <dd> <pre> cd /usr/local/mysql/bin ./mysql -h 127.0.0.1</pre> </dd> <dd> <p>The host (-h) parameter 127.0.0.1 targets the local host, but forces the mysql client to use a TCP/IP connection. The default would be a pipe/socket connection (even if you say '-h localhost') and this doesn't work between Cygwin and Windows (as far as I know).</p> </dd> <dd> <p>If you have your MySQL server running on some other box, then please substitute '127.0.0.1' with the name or IP-number of that box.</p> </dd> </dl> <p>Please note, in my environment the 'mysql' client did not accept a simple RETURN, I had to use CTRL-RETURN to send commands ... strange, but I didn't attempt to fix that, as we are only interested in the built lib and headers.</p> <p>At the 'mysql&gt;' prompt do a quick check:</p> <pre> mysql&gt; use mysql mysql&gt; show tables; mysql&gt; select * from db; mysql&gt; exit</pre> <p>You are now ready to build DBD::mysql!</p> <p>Build DBD::mysql:</p> <dl> <dt><strong>-</strong><br /> </dt> <dd> download DBD-mysql-&lt;version&gt;.tar.gz from CPAN </dd> <p></p> <dt><strong>-</strong><br /> </dt> <dd> unpack DBD-mysql-&lt;version&gt;.tar.gz </dd> <p></p> <dt><strong>-</strong><br /> </dt> <dd> cd into unpacked dir DBD-mysql-&lt;version&gt; you probably did that already, if you are reading this! </dd> <p></p> <dt><strong>-</strong><br /> </dt> <dd> <pre> cp /usr/local/mysql/bin/mysql_config .</pre> </dd> <dd> <p>This copies the executable script mentioned in the DBD::mysql docs from your just built Cywin/MySQL client directory; it knows about your Cygwin installation, especially about the right libraries to link with.</p> </dd> <dt><strong>-</strong><br /> </dt> <dd> <pre> perl Makefile.PL --testhost=127.0.0.1</pre> </dd> <dd> <p>The --testhost=127.0.0.1 parameter again forces a TCP/IP connection to the MySQL server on the local host instead of a pipe/socket connection for the 'make test' phase.</p> </dd> <dt><strong>-</strong><br /> </dt> <dd> <pre> make</pre> </dd> <dd> <p>This should run without error</p> </dd> <dt><strong>-</strong><br /> </dt> <dd> <pre> make test</pre> </dd> <dd> <p>with DBD-mysql-2.1022 or earlier you will see several errors in dbdadmin.t, mysql.t and mysql2.t; with later versions you should not get errors (except possibly one, indicating, that some tables could not be dropped. I'm hunting for a solution to that problem, but have none yet).</p> </dd> <dt><strong>-</strong><br /> </dt> <dd> <pre> make install</pre> </dd> <dd> <p>This installs DBD::mysql into the Perl hierarchy.</p> </dd> </dl> <p>Notes:</p> <p>This was tested with MySQL version 3.23.54a and DBD::mysql version 2.1022. I patched the above mentioned test scripts and sent the patches to the author of DBD::mysql Jochen Wiedman.</p> <p>Georg Rehfeld 15. Jan. 2003</p> <p> </p> <hr /> <h1><a name="known_problems">KNOWN PROBLEM/a</h1> <ol> <li><strong><a name="item__29">)</a></strong><br /> </li> Some Linux distributions don't come with a gzip library by default. Running ``make'' terminates with an error message like <pre> LD_RUN_PATH=&quot;/usr/lib/mysql:/lib:/usr/lib&quot; gcc -o blib/arch/auto/DBD/mysql/mysql.so -shared -L/usr/local/lib dbdimp.o mysql.o -L/usr/lib/mysql -lmysqlclient -lm -L/usr/lib/gcc-lib/i386-redhat-linux/2.96 -lgcc -lz /usr/bin/ld: cannot find -lz collect2: ld returned 1 exit status make: *** [blib/arch/auto/DBD/mysql/mysql.so] Error 1</pre> <p>If this is the case for you, install an RPM archive like libz-devel, libgz-devel, zlib-devel or gzlib-devel or something similar.</p> <p></p> <li><strong>)</strong><br /> </li> If Perl was compiled with gcc or egcs, but MySQL was compiled with another compiler or on another system, an error message like this is very likely when running ``Make test'': <pre> t/00base............install_driver(mysql) failed: Can't load '../blib/arch/auto/DBD/mysql/mysql.so' for module DBD::mysql: ../blib/arch/auto/DBD/mysql/mysql.so: undefined symbol: _umoddi3 at /usr/local/perl-5.005/lib/5.005/i586-linux-thread/DynaLoader.pm line 168.</pre> <p>This means, that your linker doesn't include libgcc.a. You have the following options:</p> <p>The solution is telling the linker to use libgcc. Run</p> <pre> gcc --print-libgcc-file</pre> <p>to determine the exact location of libgcc.a or for older versions of gcc</p> <pre> gcc -v</pre> <p>to determine the directory. If you know the directory, add a</p> <pre> -L&lt;directory&gt; -lgcc</pre> <p>to the list of C compiler flags. <a href="#configuration">Configuration</a>. <a href="#linker_flags">Linker flags</a>.</p> <p></p> <li><strong>)</strong><br /> </li> There are known problems with shared versions of libmysqlclient, at least on some Linux boxes. If you receive an error message similar to <pre> install_driver(mysql) failed: Can't load '/usr/lib/perl5/site_perl/i586-linux/auto/DBD/mysql/mysql.so' for module DBD::mysql: File not found at /usr/lib/perl5/i586-linux/5.00404/DynaLoader.pm line 166</pre> <p>then this error message can be misleading: It's not mysql.so that fails being loaded, but libmysqlclient.so! The usual problem is that this file is located in a directory like</p> <pre> /usr/lib/mysql</pre> <p>where the linker doesn't look for it.</p> <p>The best workaround is using a statically linked mysqlclient library, for example</p> <pre> /usr/lib/mysql/libmysqlclient.a</pre> <p>The use of a statically linked library is described in the previous section on linker flags. <a href="#configuration">Configuration</a>. <a href="#linker_flags">Linker flags</a>.</p> <p></p> <li><strong>)</strong><br /> </li> Red Hat 8 &amp; 9 set the Default locale to UTF which causes problems with MakeMaker. To build DBD::mysql on these systems, do a 'unset LANG' before runing 'perl Makefile.PL' <p></p></ol> <p> </p> <hr /> <h1><a name="support">SUPPOR/a</h1> <p>Finally, if everything else fails, you are not alone. First of all, for an immediate answer, you should look into the archives of the mailing list <strong><a href="mailto:msql-mysql-modules@lists.mysql.com">msql-mysql-modules@lists.mysql.com</a></strong>. See <a href="http://www.mysql.com">http://www.mysql.com</a> for archive locations.</p> <p>If you don't find an appropriate posting and reply in the mailing list, please post a question. Typically a reply will be seen within one or two days.</p>

</body>

</html>

1 POD Error

The following errors were encountered while parsing the POD:

Around line 394:

Deleting unknown formatting code T<>