Reputation: 1
I have installed CPAN module DBD::mysql
via sudo cpan install DBD::mysql
in order to run the code below, however I keep getting the error message:
Can't locate loadable object for module DBD::mysql in @INC (@INC contains:
/sw/lib/perl5/5.12.3/darwin-thread-multi-2level
/sw/lib/perl5/5.12.3
/sw/lib/perl5/darwin-thread-multi-2level
/sw/lib/perl5
/sw/lib/perl5/darwin
/Library/Perl/5.12/darwin-thread-multi-2level
/Library/Perl/5.12
/Network/Library/Perl/5.12/darwin-thread-multi-2level
/Network/Library/Perl/5.12
/Library/Perl/Updates/5.12.3/darwin-thread-multi-2level
/Library/Perl/Updates/5.12.3
/System/Library/Perl/5.12/darwin-thread-multi-2level
/System/Library/Perl/5.12
/System/Library/Perl/Extras/5.12/darwin-thread-multi-2level
/System/Library/Perl/Extras/5.12
.
)
at dbi_write.pl line 11
Compilation failed in require at dbi_write.pl line 11.
BEGIN failed--compilation aborted at dbi_write.pl line 11.
This is my code
#!/usr/bin/perl
#use lib '/usr/bin/cpan';
use strict;
use FileHandle;
use File::Spec;
use DBI;
use DBD::mysql;
Upvotes: 0
Views: 1728
Reputation: 1
I solved it by doing the following:
copy libmysqlclient.18.dylib into /usr/lib/
Also, there are two different Perls in my Mac OS X. One in /usr/local/ActivePerl5.16/ And another in /Systems/Library/Per/Perl5.12
Upvotes: 0
Reputation: 126722
Did your CPAN install succeed? If it did, then the module has been installed in the wrong place for the version of Perl you are running.
Look at the CPAN log to see where DBD::mysql
has been installed. The answer lies there, and the fix depends on where it has been installed and why it isn't in your Perl's @INC
.
Do you have multiple installations of Perl?
By the way, you don't have to use DBD::mysql
. DBI
will load it automatically when you call DBI->new
specifying a MySQL source. That tidies up the code at the expense of loading the driver module at run time - a small price to pay.
Upvotes: 2