fredo2906 has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I am trying to build DBD::MySQL, my compiler is MinGW and I am running WinXP. I downloaded the latest version of DBD::MySQL package. When I am using the command Perl Makefile.pl I get some error I can't get rid of.
D:\.cpan\build\DBD-mysql-4.007-5exceq>perl Makefile.PL --testhost=127. +0.0.1 --testuser=root --testpassword=sbdb "--libs=-LC:\mysql\lib -lmysqlclient -lz -lm -lcrypt -linsl" I will use the following settings for compiling and testing: cflags (guessed ) = -IC:\mysql\include embedded (guessed ) = libs (User's choice) = -LC:\mysql\lib -lmysqlclient -lz -lm + -lcrypt -linsl nocatchstderr (default ) = 0 nofoundrows (default ) = 0 ssl (guessed ) = 0 testdb (default ) = test testhost (User's choice) = 127.0.0.1 testpassword (User's choice) = sbdb testsocket (default ) = testuser (User's choice) = root To change these settings, see 'perl Makefile.PL --help' and 'perldoc INSTALL'. Checking if your kit is complete... Looks good Note (probably harmless): No library found for -lz Note (probably harmless): No library found for -lcrypt Note (probably harmless): No library found for -linsl Using DBI 1.605 (for perl 5.008008 on MSWin32-x86-multi-thread) instal +led in C:/perl/site/lib/auto/DBI/ Writing Makefile for DBD::mysql
I think the problem may come from the -lz - lcrypt -linsl but I don't know what is it for. When I execute dmake, I get some undefined reference as below:
D:\.cpan\build\DBD-mysql-4.007-5exceq>dmake gcc -c -IC:\perl\site\lib\auto\DBI -IC:\mysql\include -DDBD_MYSQL_INS +ERT_ID_IS_GOOD -g -s -O2 -DWIN32 -DHAVE_DES_FCRYPT -DPERL _IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -fno-strict-aliasing -DPERL_MSVC +RT_READFIX -s -O2 -DVERSION=\"4.007\" -DXS_VERSION=\" 4.007\" "-IC:\perl\lib\CORE" dbdimp.c gcc -c -IC:\perl\site\lib\auto\DBI -IC:\mysql\include -DDBD_MYSQL_INS +ERT_ID_IS_GOOD -g -s -O2 -DWIN32 -DHAVE_DES_FCRYPT -DPERL _IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -fno-strict-aliasing -DPERL_MSVC +RT_READFIX -s -O2 -DVERSION=\"4.007\" -DXS_VERSION=\" 4.007\" "-IC:\perl\lib\CORE" mysql.c Running Mkbootstrap for DBD::mysql () C:\perl\bin\perl.exe -MExtUtils::Command -e chmod 644 mysql.bs dlltool --def mysql.def --output-exp dll.exp C:\perl\bin\perl.exe myld g++ -o blib\arch\auto\DBD\mysql\mysql.dll -W +l,--base-file -Wl,dll.base -mdll -s -L"c:\perl\lib\CORE" -L"C:\Mi nGW\lib" dbdimp.o mysql.o -Wl,--image-base,0x1570000 C:\perl\li +b\CORE\libperl58.a C:\mysql\lib\libmysqlclient.a C:\MinGW\lib\lib m.a C:\MinGW\lib\libmsvcrt.a C:\MinGW\lib\libmoldname.a C:\MinGW\lib\l +ibkernel32.a C:\MinGW\lib\libuser32.a C:\MinGW\lib\libgdi32.a C:\ MinGW\lib\libwinspool.a C:\MinGW\lib\libcomdlg32.a C:\MinGW\lib\libadv +api32.a C:\MinGW\lib\libshell32.a C:\MinGW\lib\libole32.a C:\MinG W\lib\liboleaut32.a C:\MinGW\lib\libnetapi32.a C:\MinGW\lib\libuuid.a +C:\MinGW\lib\libws2_32.a C:\MinGW\lib\libmpr.a C:\MinGW\lib\libwi nmm.a C:\MinGW\lib\libversion.a C:\MinGW\lib\libodbc32.a C:\MinGW\lib\ +libodbccp32.a dll.exp dbdimp.o: In function `mysql_db_FETCH_attrib': D:/.cpan/build/DBD-mysql-4.007-5exceq/dbdimp.c:2256: undefined referen +ce to `mysql_insert_id@4' D:/.cpan/build/DBD-mysql-4.007-5exceq/dbdimp.c:2261: undefined referen +ce to `mysql_get_proto_info@4' D:/.cpan/build/DBD-mysql-4.007-5exceq/dbdimp.c:2294: undefined referen +ce to `mysql_thread_id@4' D:/.cpan/build/DBD-mysql-4.007-5exceq/dbdimp.c:2242: undefined referen +ce to `mysql_get_host_info@4' D:/.cpan/build/DBD-mysql-4.007-5exceq/dbdimp.c:2251: undefined referen +ce to `mysql_info@4' D:/.cpan/build/DBD-mysql-4.007-5exceq/dbdimp.c:2267: undefined referen +ce to `mysql_get_server_info@4' D:/.cpan/build/DBD-mysql-4.007-5exceq/dbdimp.c:2277: undefined referen +ce to `mysql_stat@4' D:/.cpan/build/DBD-mysql-4.007-5exceq/dbdimp.c:2284: undefined referen +ce to `mysql_stat@4' dbdimp.o: In function `mysql_st_free_result_sets': D:/.cpan/build/DBD-mysql-4.007-5exceq/dbdimp.c:2629: undefined referen +ce to `mysql_free_result@4' dbdimp.o: In function `mysql_st_fetch': D:/.cpan/build/DBD-mysql-4.007-5exceq/dbdimp.c:3514: undefined referen +ce to `mysql_fetch_row@4' D:/.cpan/build/DBD-mysql-4.007-5exceq/dbdimp.c:3533: undefined referen +ce to `mysql_num_fields@4' D:/.cpan/build/DBD-mysql-4.007-5exceq/dbdimp.c:3534: undefined referen +ce to `mysql_fetch_fields@4' D:/.cpan/build/DBD-mysql-4.007-5exceq/dbdimp.c:3535: undefined referen +ce to `mysql_fetch_lengths@4' D:/.cpan/build/DBD-mysql-4.007-5exceq/dbdimp.c:3504: undefined referen +ce to `mysql_num_fields@4' D:/.cpan/build/DBD-mysql-4.007-5exceq/dbdimp.c:3506: undefined referen +ce to `mysql_num_rows@4' D:/.cpan/build/DBD-mysql-4.007-5exceq/dbdimp.c:3508: undefined referen +ce to `mysql_affected_rows@4' dbdimp.o: In function `mysql_st_FETCH_internal': D:/.cpan/build/DBD-mysql-4.007-5exceq/dbdimp.c:3889: undefined referen +ce to `mysql_field_seek@8' D:/.cpan/build/DBD-mysql-4.007-5exceq/dbdimp.c:3967: undefined referen +ce to `mysql_fetch_field@4' D:/.cpan/build/DBD-mysql-4.007-5exceq/dbdimp.c:3967: undefined referen +ce to `mysql_fetch_field@4' dbdimp.o: In function `mysql_st_internal_execute': D:/.cpan/build/DBD-mysql-4.007-5exceq/dbdimp.c:2889: undefined referen +ce to `mysql_list_fields@12' D:/.cpan/build/DBD-mysql-4.007-5exceq/dbdimp.c:2917: undefined referen +ce to `mysql_use_result@4' D:/.cpan/build/DBD-mysql-4.007-5exceq/dbdimp.c:2925: undefined referen +ce to `mysql_affected_rows@4' D:/.cpan/build/DBD-mysql-4.007-5exceq/dbdimp.c:2917: undefined referen +ce to `mysql_store_result@4' D:/.cpan/build/DBD-mysql-4.007-5exceq/dbdimp.c:2927: undefined referen +ce to `mysql_num_rows@4' D:/.cpan/build/DBD-mysql-4.007-5exceq/dbdimp.c:571: undefined referenc +e to `mysql_real_escape_string@16' dbdimp.o: In function `mysql_st_execute': D:/.cpan/build/DBD-mysql-4.007-5exceq/dbdimp.c:3140: undefined referen +ce to `mysql_insert_id@4' D:/.cpan/build/DBD-mysql-4.007-5exceq/dbdimp.c:3144: undefined referen +ce to `mysql_num_fields@4' dbdimp.o: In function `mysql_db_quote': D:/.cpan/build/DBD-mysql-4.007-5exceq/dbdimp.c:4562: undefined referen +ce to `mysql_real_escape_string@16' dbdimp.o: In function `mysql_db_last_insert_id': D:/.cpan/build/DBD-mysql-4.007-5exceq/dbdimp.c:4585: undefined referen +ce to `mysql_insert_id@4' mysql.o: In function `XS_DBD__mysql__dr__ListDBs': D:/.cpan/build/DBD-mysql-4.007-5exceq/mysql.xs:54: undefined reference + to `mysql_list_dbs@8' D:/.cpan/build/DBD-mysql-4.007-5exceq/mysql.xs:61: undefined reference + to `mysql_num_rows@4' D:/.cpan/build/DBD-mysql-4.007-5exceq/mysql.xs:64: undefined reference + to `mysql_fetch_row@4' D:/.cpan/build/DBD-mysql-4.007-5exceq/mysql.xs:66: undefined reference + to `mysql_free_result@4' D:/.cpan/build/DBD-mysql-4.007-5exceq/mysql.xs:61: undefined reference + to `mysql_num_rows@4' mysql.o: In function `XS_DBD__mysql__dr__admin_internal': D:/.cpan/build/DBD-mysql-4.007-5exceq/mysql.xs:109: undefined referenc +e to `mysql_shutdown@4' D:/.cpan/build/DBD-mysql-4.007-5exceq/mysql.xs:114: undefined referenc +e to `mysql_refresh@8' mysql.o: In function `XS_DBD__mysql__db__ListDBs': D:/.cpan/build/DBD-mysql-4.007-5exceq/mysql.xs:204: undefined referenc +e to `mysql_list_dbs@8' D:/.cpan/build/DBD-mysql-4.007-5exceq/mysql.xs:215: undefined referenc +e to `mysql_num_rows@4' D:/.cpan/build/DBD-mysql-4.007-5exceq/mysql.xs:218: undefined referenc +e to `mysql_fetch_row@4' D:/.cpan/build/DBD-mysql-4.007-5exceq/mysql.xs:220: undefined referenc +e to `mysql_free_result@4' D:/.cpan/build/DBD-mysql-4.007-5exceq/mysql.xs:215: undefined referenc +e to `mysql_num_rows@4' D:/.cpan/build/DBD-mysql-4.007-5exceq/mysql.xs:206: undefined referenc +e to `mysql_list_dbs@8' mysql.o: In function `XS_DBD__mysql__db_do': D:/.cpan/build/DBD-mysql-4.007-5exceq/mysql.xs:492: undefined referenc +e to `mysql_free_result@4' mysql.o: In function `XS_DBD__mysql__db_ping': D:/.cpan/build/DBD-mysql-4.007-5exceq/mysql.xs:513: undefined referenc +e to `mysql_ping@4' D:/.cpan/build/DBD-mysql-4.007-5exceq/mysql.xs:516: undefined referenc +e to `mysql_ping@4' mysql.o: In function `XS_DBD__mysql__st_dataseek': D:/.cpan/build/DBD-mysql-4.007-5exceq/mysql.xs:598: undefined referenc +e to `mysql_data_seek@12' mysql.o: In function `XS_DBD__mysql__GetInfo_dbd_mysql_get_info': D:/.cpan/build/DBD-mysql-4.007-5exceq/mysql.xs:686: undefined referenc +e to `mysql_get_server_info@4' D:/.cpan/build/DBD-mysql-4.007-5exceq/mysql.xs:690: undefined referenc +e to `mysql_get_parameters@0' collect2: ld returned 1 exit status dmake: Error code 129, while making 'blib\arch\auto\DBD\mysql\mysql.d +ll'
Could you please help me on this?

Replies are listed 'Best First'.
Re: How to build DBD::MySQL
by dragonchild (Archbishop) on Jul 15, 2008 at 02:55 UTC
    You need to install/compile libz, libcrypt, and libinsl. Google for them.

    My criteria for good software:
    1. Does it work?
    2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
Re: How to build DBD::MySQL
by CountZero (Bishop) on Jul 15, 2008 at 05:57 UTC
    DBD::MySQL has a very bad record of compiling on Windows machines: see CPAN Test reports.

    The various PPM-repositories show version 4.005 to be most recent available (thanks to Randy Kobes).

    You might consider asking Randy how he pulled that magic trick!

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Re: How to build DBD::MySQL
by oko1 (Deacon) on Jul 15, 2008 at 02:56 UTC

    From the 'gcc' manpage (trimmed for context):

           -llibrary
               Search the library named library when linking.
    
               The linker searches a standard list of directories for the library, which is actually a file named liblibrary.a.
               The linker then uses this file as if it had been specified precisely by name.
    

    In other words, you need to make sure that you have the appropriate development library files - i.e., "liblz.a", "libcrypt.a", and "libinsl.a" - installed on your system, in the appropriate directories (where the compiler will find them.)

    
    -- 
    Human history becomes more and more a race between education and catastrophe. -- HG Wells
    
Re: How to build DBD::MySQL
by almut (Canon) on Jul 15, 2008 at 04:15 UTC

    Presumably, you're missing the proper declarations in the mysql.def file — in case you have one at all... (?)  If you have one, what does it contain? In particular, does it contain the referenced symbols such as 'mysql_insert_id@4', etc.?  The .def file is used by dlltool to create the exports section of a DLL.

    See Create Import Libraries for what this is about, and how you might create the .def file.  reimp from the mingw-utils might help, too, to create a .def file.

    (That said, before investing too much time, if I were you I'd probably first try hard to dig up a precompiled version of the module instead...)

      Thanks for your help. Here were my procedure: cd c:\mysql\lib\opt reimp libmysql.lib rename LIBMYSQL.def libmysql.def dlltool --input-def libmysql.def --dllname libmysql.dll --output-lib mysql.a rename liblibmysql.a libmysql.a I added this parameter to the perl makefile.pl -LC:\Programs\mysql-4.1.12-win32\lib\opt -lmysql Nevertheless I still get the following error:
      D:\TMP\DBD-mysql-4.007>dmake gcc -c -IC:\perl\site\lib\auto\DBI -IC:\mysql\include -DDBD_MYSQL_INS +ERT_ID_IS_GOOD -g -s -O2 -DWIN32 -DHAVE_DES_FCRYPT -DPERL _IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -fno-strict-aliasing -DPERL_MSVC +RT_READFIX -s -O2 -DVERSION=\"4.007\" -DXS_VERSION=\" 4.007\" "-IC:\perl\lib\CORE" dbdimp.c gcc -c -IC:\perl\site\lib\auto\DBI -IC:\mysql\include -DDBD_MYSQL_INS +ERT_ID_IS_GOOD -g -s -O2 -DWIN32 -DHAVE_DES_FCRYPT -DPERL _IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -fno-strict-aliasing -DPERL_MSVC +RT_READFIX -s -O2 -DVERSION=\"4.007\" -DXS_VERSION=\" 4.007\" "-IC:\perl\lib\CORE" mysql.c Running Mkbootstrap for DBD::mysql () C:\perl\bin\perl.exe -MExtUtils::Command -e chmod 644 mysql.bs dlltool --def mysql.def --output-exp dll.exp C:\perl\bin\perl.exe myld g++ -o blib\arch\auto\DBD\mysql\mysql.dll -W +l,--base-file -Wl,dll.base -mdll -s -L"c:\perl\lib\CORE" -L"C:\Mi nGW\lib" dbdimp.o mysql.o -Wl,--image-base,0x1570000 C:\perl\li +b\CORE\libperl58.a C:\MinGW\lib\libmysql.a C:\MinGW\lib\libmsvcrt .a C:\MinGW\lib\libmoldname.a C:\MinGW\lib\libkernel32.a C:\MinGW\lib\ +libuser32.a C:\MinGW\lib\libgdi32.a C:\MinGW\lib\libwinspool.a C: \MinGW\lib\libcomdlg32.a C:\MinGW\lib\libadvapi32.a C:\MinGW\lib\libsh +ell32.a C:\MinGW\lib\libole32.a C:\MinGW\lib\liboleaut32.a C:\Min GW\lib\libnetapi32.a C:\MinGW\lib\libuuid.a C:\MinGW\lib\libws2_32.a C +:\MinGW\lib\libmpr.a C:\MinGW\lib\libwinmm.a C:\MinGW\lib\libvers ion.a C:\MinGW\lib\libodbc32.a C:\MinGW\lib\libodbccp32.a dll.exp dbdimp.o: In function `dbd_discon_all': D:/TMP/DBD-mysql-4.007/dbdimp.c:1972: undefined reference to `mysql_se +rver_end@0' collect2: ld returned 1 exit status dmake: Error code 129, while making 'blib\arch\auto\DBD\mysql\mysql.d +ll'
      Thanks for your help.
      Here were my procedure:

      cd c:\mysql\lib\opt
      reimp libmysql.lib
      rename LIBMYSQL.def libmysql.def
      dlltool --input-def libmysql.def --dllname libmysql.dll --output-lib mysql.a rename liblibmysql.a libmysql.a
      I added this parameter to the perl makefile.pl
      -LC:\Programs\mysql-4.1.12-win32\lib\opt
      -lmysql
      Nevertheless I still get the following error:
      D:\TMP\DBD-mysql-4.007>dmake gcc -c -IC:\perl\site\lib\auto\DBI -IC:\mysql\include -DDBD_MYSQL_INS +ERT_ID_IS_GOOD -g -s -O2 -DWIN32 -DHAVE_DES_FCRYPT -DPERL _IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -fno-strict-aliasing -DPERL_MSVC +RT_READFIX -s -O2 -DVERSION=\"4.007\" -DXS_VERSION=\" 4.007\" "-IC:\perl\lib\CORE" dbdimp.c gcc -c -IC:\perl\site\lib\auto\DBI -IC:\mysql\include -DDBD_MYSQL_INS +ERT_ID_IS_GOOD -g -s -O2 -DWIN32 -DHAVE_DES_FCRYPT -DPERL _IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -fno-strict-aliasing -DPERL_MSVC +RT_READFIX -s -O2 -DVERSION=\"4.007\" -DXS_VERSION=\" 4.007\" "-IC:\perl\lib\CORE" mysql.c Running Mkbootstrap for DBD::mysql () C:\perl\bin\perl.exe -MExtUtils::Command -e chmod 644 mysql.bs dlltool --def mysql.def --output-exp dll.exp C:\perl\bin\perl.exe myld g++ -o blib\arch\auto\DBD\mysql\mysql.dll -W +l,--base-file -Wl,dll.base -mdll -s -L"c:\perl\lib\CORE" -L"C:\Mi nGW\lib" dbdimp.o mysql.o -Wl,--image-base,0x1570000 C:\perl\li +b\CORE\libperl58.a C:\MinGW\lib\libmysql.a C:\MinGW\lib\libmsvcrt .a C:\MinGW\lib\libmoldname.a C:\MinGW\lib\libkernel32.a C:\MinGW\lib\ +libuser32.a C:\MinGW\lib\libgdi32.a C:\MinGW\lib\libwinspool.a C: \MinGW\lib\libcomdlg32.a C:\MinGW\lib\libadvapi32.a C:\MinGW\lib\libsh +ell32.a C:\MinGW\lib\libole32.a C:\MinGW\lib\liboleaut32.a C:\Min GW\lib\libnetapi32.a C:\MinGW\lib\libuuid.a C:\MinGW\lib\libws2_32.a C +:\MinGW\lib\libmpr.a C:\MinGW\lib\libwinmm.a C:\MinGW\lib\libvers ion.a C:\MinGW\lib\libodbc32.a C:\MinGW\lib\libodbccp32.a dll.exp dbdimp.o: In function `dbd_discon_all': D:/TMP/DBD-mysql-4.007/dbdimp.c:1972: undefined reference to `mysql_se +rver_end@0' collect2: ld returned 1 exit status dmake: Error code 129, while making 'blib\arch\auto\DBD\mysql\mysql.d +ll'

        I'm no expert in the specifics of the DBD::mysql build process, but this line in the make messages

        dlltool --def mysql.def --output-exp dll.exp

        looks as if it's trying to create a dll.exp itself (from a mysql.def), which is then being referenced in the subsequent compile/link step.  In other words, I would not try to create a libmysql.a myself, but rather just rename the output of "reimp libmysql.lib" to mysql.def, and leave the rest to the build process as is...  Just an idea, though. Hope it helps.

        (Be sure to also check whether the .def file does in fact contain the symbols that are being reported as "undefined"...)

Re: How to build DBD::MySQL
by Limbic~Region (Chancellor) on Jul 15, 2008 at 13:52 UTC
    fredo2906,
    See DBD::mysql installation. I ended up having to use a combination of Cygwin and Windows but MinGW should be able to do the same. You might want to start at this point in the thread.

    Cheers - L~R

      Can you explain your procedure ?
        fredo2906,
        Given that it was more than 3 years ago and I only did it once, probably not. The basic outline was this:
        • Install MySQL Server for Windows
        • Ensure the client libraries are NOT in PATH
        • Compile the client libraries from source in Cygwin
        • Ensure the Cygwin client libraries are in PATH
        • Compile and install DBD::mysql in Cygwin using this guide

        Note: The guide referenced in the last step actually points to various other resources.

        Cheers - L~R