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

Hi I'm trying to install the Perl module DBI to enable me to access a MySQL database. I'm entering the following command via the Windows Command Prompt (running Windows 7): cpanm DBI It starts running, but after a minute or so I get the pop-up error telling me that the Command Prompt has stopped working - I get this several times until the install fails. Complete list of what is display in the command prompt below:
C:\cpanm DBI Set up gcc environment - gcc.exe (rubenvb-4.5.4) 4.5.4 --> Working on DBI Fetching http://www.cpan.org/authors/id/T/TI/TIMB/DBI-1.633.tar.gz ... + OK Configuring DBI-1.633 ... OK Building and testing DBI-1.633 ... FAIL ! Installing DBI failed. See C:\Users\Colin\.cpanm\work\1424190404.579 +6\build.log for details. Retry with --force to force install it.
I've tried the --force which came up with the same error but informed me that it has installed anyway but does not appear to have worked as my Perl program cannot find the module. Any ideas where I'm going wrong greatly appreciated - I've installed Perl modules using this method before without these kind of issues. Still new to working with Perl! So hopefully something simple I've missed. Thanks Colin

Replies are listed 'Best First'.
Re: Trying to install DBI
by choroba (Cardinal) on Feb 17, 2015 at 17:09 UTC
    The error gives you enough information for the next step: See the mentioned log for details. If in doubt, paste the relevant parts of the log here.
    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
      Yes, it was kind of telling me where to look - trying to do too many things at once. The original problem as the log pointed out was that I did not have a path to the MySQL bin folder. Fixed that... but the install still failed... but because I used the --force it installed anyway - last few lines of the log as follows:
      Non-zero exit status: 38 Parse errors: Bad plan. You planned 60 tests but ran 0. t/zvg_43prof_env.t (Wstat: 9728 Tests: 11 Failed: 0) Non-zero exit status: 38 Files=182, Tests=7257, 137 wallclock secs ( 1.59 usr + 0.81 sys = 2. +40 CPU) Result: FAIL Failed 10/182 test programs. 0/7257 subtests failed. dmake.exe: Error code 255, while making 'test_dynamic' -> FAIL Testing DBI-1.633 failed but installing it anyway. Files found in blib\arch: installing files in blib\lib into architectu +re dependent library tree Installing C:\Perl64\site\lib\auto\DBI\DBI.dll Appending installation info to C:\Perl64\lib/perllocal.pod dmake.exe: Warning: -- Target [install] was made but the time stamp h +as not been updated. -> OK Successfully reinstalled DBI-1.633 1 distribution installed
      If I try and install without the --force I get a message saying the module is up-to-date. perldoc DBI also returns information however my test connect to the database (test Perl program) is returning the following error still:
      install_driver(mysql) failed: Can't locate DBD/mysql.pm in @INC (@INC +contains: C:/Perl64/site/lib/MSWin32-x64-multi-thread C:/Perl64/site/ +lib C:/Perl64/lib .) at (eval 5) line 3. Perhaps the DBD::mysql perl module hasn't been fully installed, or perhaps the capitalisation of 'mysql' isn't right. Available drivers: CSV, DBM, ExampleP, File, Gofer, ODBC, Oracle, Pg, +Proxy, SQLite, Sponge. at C:\BATHGATE_WEATHER_OBSERVATION_SYSTEM\PERL\TEST_SQL.pl line 12.
      Code for the test Perl program is...
      #! c:\xampp\perl\bin\perl use strict; use warnings; use DBI; my $dsn = "DBI:mysql:weather"; my $db_user = "colin"; my $db_pass = "???????????"; my $dbh = DBI->connect ($dsn,$db_user,$db_pass) or die "Couldn't connect to MySQL.\n"; print "Connection Successful: \$dbh=$dbh\n"; my $sql = "select station_id, station_name from stations"; my $sth = $dbh->prepare($sql) or die "Couldn't prepare statement $sql.\n"; $sth->execute() or die "Couldn't execute statement $sql.\n"; $sth->finish; $dbh->disconnect; exit;
      This appears to suggest that DBD:mysql is not installed, tried to install this module but it also failed with the following ending to the log file:
      C:\Users\Colin\.cpanm\work\1424205331.7856\DBD-mysql-4.029/mysql.xs:68 +: undefined reference to `mysql_error' C:\Users\Colin\.cpanm\work\1424205331.7856\DBD-mysql-4.029/mysql.xs:68 +: undefined reference to `mysql_errno' collect2: ld returned 1 exit status dmake.exe: Error code 129, while making 'blib\arch\auto\DBD\mysql\mys +ql.dll' -> FAIL Installing DBD::mysql failed. See C:\Users\Colin\.cpanm\work\1 +424205331.7856\build.log for details. Retry with --force to force ins +tall it.
      This module will not install with -force and does not show up anything when I enter perldocs DBD::MySQL Not sure what to do next, do I need both modules, DBI and DBD::MySQL? I can provide full log data if required... Thanks for any help on this... Colin
Re: Trying to install DBI
by vinoth.ree (Monsignor) on Feb 17, 2015 at 17:39 UTC

    Hi ureco,

    As choroba suggested look into the build.log file it might failed in Building and testing DBI-1.633.

    Go into .cpanm, is there a build/source directory where DBI-1.633 is located Go there and run 'make test' and redirect the output to a file that you can see failing test cases and read it.

    The verbose output should be in the build.log. Try cpanm --verbose DBI. That will give you the full information on screen.


    All is well
Re: Trying to install DBI
by ureco (Acolyte) on Feb 18, 2015 at 09:10 UTC
    After much hunting last night (finished too late to post here) I discovered a different method to install this module. By going into the Perl/bin folder and typing the following:
    ppm install DBD-MySQL
    I managed to install the module successfully and my Perl test is now working fine. Don't know what occurred with the cpanm install method but I'm up and running so won't worry too much about that.