problems installing DBI and DBD:Oracle modules

ok, this is the problem i am having. i am trying to run Perl on Windows, so i installed ActiveState Perl. so i ran a small Hello World program and it worked fine. But then i needed to pull data from an Oracle database, so installed the DBI and DBD:Oracle modules from the CPAN site. i followed the instructions in the README files, but i must have done something wrong because i am the getting the foloowing error in a small Perl program for accessing an Oracle db:

  can't locate object method "connect" via package "DBI"

and here is the source of the program:

#!/usr/bin/perl
use lib "/DBI/DBI-1.45/DBI";

       #database connection variables;
  my $dbname   = "dbname";
  my $user     = "username";
  my $password = "password";

       #connection string for the database, change this with change of db;
  $connect_string = "dbi:Oracle:$dbname";

       #the actual connection string for the database;
  $dbh = DBI->connect($connect_string, "$user", "$password")
         or die "Could not open database: " . $DBI::errstr;


     #disconnecting the database handle;
$dbh->disconnect
      or print ERROR "Error disconnecting: $DBI::errstr";

print "end program\n";
exit;

On line 2 i have 'use lib "/DBI/DBI-1.45/DBI"' instead of 'use DBI' because that's the directory i installed DBI in.

any ideas what the problem could be?

Thanks.
Lou1Asked:
Who is Participating?
 
kanduraConnect With a Mentor Commented:
Lou1,
> ok, so what's PPM? i launched CygWin and typed "ppm" but it said "command
> not found". i am running my Perl through CygWin, i.e. i am on a Windows
> XP machine so what i did was this:

Combining Cygwin and Activestate perl should work, but it's an odd combination. Either get a Cygwin version of perl, or install packages outside of cygwin.
FYI, PPM is Activestate's Perl Package Manager; it's their interface to install binary (i.e. precompiled) packages compatible with Activestate perl.
I tried running ppm through Cygwin, and also got Command not found. Try "ppm.bat" instead.

This: "/usr/lib/perl5/site_perl/5.8.5/cygwin-thread-multi-64int/" looks like you also have a Cygwin version of perl installed. I'm pretty sure that complicates matters.
In any case, the biggest problem you're facing is that of binary compatibility. ActiveState's perl is compiled with MSVC, while the Cygwin one is compiled with gcc. Building modules from source must be done with the same compiler. I guess that accounts for the errors you got:

> dbdimp.c:19:20: stdafx.h: No such file or directory
That is a typical MSVC header file.

I suggest you make sure your environment is consistent. Either go with Cygwin, or go with ActiveState. If you choose the latter, then try to install binary packages if at all possible.
I found some instructions on installing DBI and DBD::Oracle here: http://www.codecomments.com/PERL_DBI/message296574.html
Here's the relevant quote:

    The good way to install DBD::Oracle is like they tell you to do:
   
    1. Find out exact perl-version with "perl -v", for example 5.8.4
    2. ppm remove DBI
    3. ppm install http://ftp.esoftmatic.com/outgoing/DBI/5.8.4/DBI.ppd
    4. ppm install http://ftp.esoftmatic.com/outgoing/.../DBD-Oracle.ppd
   
    FIRST install DBI, THEN install the real database drivers DBD::Oracle etc.
0
 
Lou1Author Commented:
btw, that's "connect" there, not :connect"
0
 
Felix2000Commented:
Try this

require <path to DBI>/DBI.pm

eg. require /DBI/DBI-1.45/DBI.pm


-= Felix =-
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
kanduraCommented:
you still need to "use DBI"; since "use lib ..." only adds that directory to the search path where perl looks for modules.
0
 
Lou1Author Commented:
ok, now i did this:

.........................................
 use lib "c:/Perl/lib/DBI/DBI-1.45";
use DBI;
 
       #database connection variables;
  my $dbname   = "dbname";
  my $user     = "username";
  my $password = "password";.................................
....................................................

  and i am getting the following error:

  can't locate loadable object for module DBI in @INC(@INC contains: c:/Perl/lib/DBI/DBI-1.45 c:/Perl/lib c:/Perl/site/lib .) at c:/Perl/lib/DBI/DBI-1.45/DBI.pm line 254

where line 254 is:

  Exporter::export_ok_tags(keys %EXPORT_TAGS);
0
 
kanduraCommented:
you need to install the module properly. It should not have gone in a separate directory like that. It can't find the other parts that come with the installation, which should have gone into the lib/auto/DBI directory.

I'd suggest you rerun the installation, and this time just install the binary package with ppm. A simple "ppm install DBI" will do the trick for you.
0
 
Lou1Author Commented:
ok, so what's PPM? i launched CygWin and typed "ppm" but it said "command not found". i am running my Perl through CygWin, i.e. i am on a Windows XP machine so what i did was this:
 
 1. i installed CygWin and when i launcg it i am in directory "C:\Documents and Settings\myusername"
 2. i installed ActiveState Perl. i think that went in "C:\Perl"
 3. i installed DBI 1.45 in directory "C:\Documents and Settings\myusername\cygwin", i.e. i unpacked the module files and extracted them in that directory and then did:
             perl makefile.pl
             make
             make test
             make install
           
 4. i installed DBD Oracle in the same directory, i.e. i unpacked the module files and extracted them in "C:\Documents and Settings\myusername\cygwin\DBI-1.45" and did:
             perl makefile.pl
             make
             make test
             make install

i don't remember if i got any errors while doing 3 and 4.
0
 
Lou1Author Commented:
ok, i think i installed DBI successfully, now i am struggling with DBD:Oracle. i am getting some kind of error. here is my listing:

  $ perl makefile.pl
Using DBI 1.45 (for perl 5.008005 on cygwin-thread-multi-64int) installed in /us
r/lib/perl5/site_perl/5.8.5/cygwin-thread-multi-64int/auto/DBI/

 Configuring DBD::Oracle ...

>>>     Remember to actually *READ* the README file!
        Especially if you have any problems.

Using Oracle in /cygdrive/C/Oracle/Ora81
I'm having trouble finding your Oracle version number... trying harder
Oracle version 8.1.0 (8.1)
Found oci directory
Using OCI directory 'oci'

Checking for functioning wait.ph


System: perl5.008005 cygwin_nt-5.1 inspiron 1.5.10(0.11642) 2004-05-25 22:07 i68
6 unknown unknown cygwin
Compiler:   gcc -O2 -DPERL_USE_SAFE_PUTENV -fno-strict-aliasing -pipe -I/usr/loc
al/include
Linker:     /usr/bin/ld
Sysliblist:


Warning: If you have problems you may need to rebuild perl with -Uusemymalloc.

LD_RUN_PATH=/cygdrive/C/Oracle/Ora81/lib:/cygdrive/C/Oracle/Ora81/rdbms/lib
Using DBD::Oracle 1.16.
Using DBD::Oracle 1.16.
Using DBI 1.45 (for perl 5.008005 on cygwin-thread-multi-64int) installed in /us
r/lib/perl5/site_perl/5.8.5/cygwin-thread-multi-64int/auto/DBI/
Writing Makefile for DBD::Oracle

***  If you have problems...
     read all the log printed above, and the README and README.help files.
     (Of course, you have read README by now anyway, haven't you?)


lvassilev@CM12228989 /cygdrive/c/cygwin/lib/perl5/site_perl/5.8.5/cygwin-thread-
multi-64int/DBD
$ make
Skip blib/lib/DBD/Oracle.pm (unchanged)
Skip blib/lib/DBD/DBM.pm (unchanged)
Skip blib/lib/DBD/test1.pl (unchanged)
Skip blib/lib/DBD/Sponge.pm (unchanged)
Skip blib/lib/oraperl.ph (unchanged)
Skip blib/arch/auto/DBD/Oracle/dbdimp.h (unchanged)
Skip blib/lib/DBD/Proxy.pm (unchanged)
Skip blib/arch/auto/DBD/Oracle/ocitrace.h (unchanged)
Skip blib/lib/Oraperl.pm (unchanged)
Skip blib/lib/DBD/File.pm (unchanged)
Skip blib/arch/auto/DBD/Oracle/Oracle.h (unchanged)
Skip blib/lib/DBD/NullP.pm (unchanged)
Skip blib/lib/DBD/ExampleP.pm (unchanged)
Skip blib/lib/DBD/Oracle/GetInfo.pm (unchanged)
cp mk.pm blib/arch/auto/DBD/Oracle/mk.pm
gcc -c  -I/cygdrive/C/Oracle/Ora81/oci/include -I/cygdrive/C/Oracle/Ora81/rdbms/
demo -I/usr/lib/perl5/site_perl/5.8.5/cygwin-thread-multi-64int/auto/DBI/ -DPERL
_USE_SAFE_PUTENV -fno-strict-aliasing -pipe -I/usr/local/include -DUSEIMPORTLIB
-O2   -DVERSION=\"1.16\" -DXS_VERSION=\"1.16\"  "-I/usr/lib/perl5/5.8.5/cygwin-t
hread-multi-64int/CORE"  -Wall -Wno-comment -DUTF8_SUPPORT -DORA_OCI_VERSION=\"8
.1.0\" Oracle.c
gcc -c  -I/cygdrive/C/Oracle/Ora81/oci/include -I/cygdrive/C/Oracle/Ora81/rdbms/
demo -I/usr/lib/perl5/site_perl/5.8.5/cygwin-thread-multi-64int/auto/DBI/ -DPERL
_USE_SAFE_PUTENV -fno-strict-aliasing -pipe -I/usr/local/include -DUSEIMPORTLIB
-O2   -DVERSION=\"1.16\" -DXS_VERSION=\"1.16\"  "-I/usr/lib/perl5/5.8.5/cygwin-t
hread-multi-64int/CORE"  -Wall -Wno-comment -DUTF8_SUPPORT -DORA_OCI_VERSION=\"8
.1.0\" dbdimp.c
dbdimp.c:19:20: stdafx.h: No such file or directory
dbdimp.c: In function `ora_db_login6':
dbdimp.c:283: warning: unused variable `o'
dbdimp.c:284: warning: unused variable `l'
dbdimp.c:315: warning: cast to pointer from integer of different size
dbdimp.c:329: warning: cast to pointer from integer of different size
dbdimp.c:339: warning: cast to pointer from integer of different size
dbdimp.c:343: warning: cast to pointer from integer of different size
dbdimp.c:386: warning: unused variable `rsize'
dbdimp.c: In function `dbd_rebind_ph_char':
dbdimp.c:1121: warning: cast from pointer to integer of different size
make: *** [dbdimp.o] Error 1

lvassilev@CM12228989 /cygdrive/c/cygwin/lib/perl5/site_perl/5.8.5/cygwin-thread-
multi-64int/DBD
$ make test
gcc -c  -I/cygdrive/C/Oracle/Ora81/oci/include -I/cygdrive/C/Oracle/Ora81/rdbms/
demo -I/usr/lib/perl5/site_perl/5.8.5/cygwin-thread-multi-64int/auto/DBI/ -DPERL
_USE_SAFE_PUTENV -fno-strict-aliasing -pipe -I/usr/local/include -DUSEIMPORTLIB
-O2   -DVERSION=\"1.16\" -DXS_VERSION=\"1.16\"  "-I/usr/lib/perl5/5.8.5/cygwin-t
hread-multi-64int/CORE"  -Wall -Wno-comment -DUTF8_SUPPORT -DORA_OCI_VERSION=\"8
.1.0\" dbdimp.c
dbdimp.c:19:20: stdafx.h: No such file or directory
dbdimp.c: In function `ora_db_login6':
dbdimp.c:283: warning: unused variable `o'
dbdimp.c:284: warning: unused variable `l'
dbdimp.c:315: warning: cast to pointer from integer of different size
dbdimp.c:329: warning: cast to pointer from integer of different size
dbdimp.c:339: warning: cast to pointer from integer of different size
dbdimp.c:343: warning: cast to pointer from integer of different size
dbdimp.c:386: warning: unused variable `rsize'
dbdimp.c: In function `dbd_rebind_ph_char':
dbdimp.c:1121: warning: cast from pointer to integer of different size
make: *** [dbdimp.o] Error 1

lvassilev@CM12228989 /cygdrive/c/cygwin/lib/perl5/site_perl/5.8.5/cygwin-thread-
multi-64int/DBD
$ make install
gcc -c  -I/cygdrive/C/Oracle/Ora81/oci/include -I/cygdrive/C/Oracle/Ora81/rdbms/
demo -I/usr/lib/perl5/site_perl/5.8.5/cygwin-thread-multi-64int/auto/DBI/ -DPERL
_USE_SAFE_PUTENV -fno-strict-aliasing -pipe -I/usr/local/include -DUSEIMPORTLIB
-O2   -DVERSION=\"1.16\" -DXS_VERSION=\"1.16\"  "-I/usr/lib/perl5/5.8.5/cygwin-t
hread-multi-64int/CORE"  -Wall -Wno-comment -DUTF8_SUPPORT -DORA_OCI_VERSION=\"8
.1.0\" dbdimp.c
dbdimp.c:19:20: stdafx.h: No such file or directory
dbdimp.c: In function `ora_db_login6':
dbdimp.c:283: warning: unused variable `o'
dbdimp.c:284: warning: unused variable `l'
dbdimp.c:315: warning: cast to pointer from integer of different size
dbdimp.c:329: warning: cast to pointer from integer of different size
dbdimp.c:339: warning: cast to pointer from integer of different size
dbdimp.c:343: warning: cast to pointer from integer of different size
dbdimp.c:386: warning: unused variable `rsize'
dbdimp.c: In function `dbd_rebind_ph_char':
dbdimp.c:1121: warning: cast from pointer to integer of different size
make: *** [dbdimp.o] Error 1

lvassilev@CM12228989 /cygdrive/c/cygwin/lib/perl5/site_perl/5.8.5/cygwin-thread-
multi-64int/DBD
$ perl -MDBD::Oracle -e 0
Can't load '/cygdrive/c/Oracle/Ora81/bin/Oracle' for module DBD::Oracle: dlopen,
 Win32 error 126 at /usr/lib/perl5/5.8.5/cygwin-thread-multi-64int/DynaLoader.pm
 line 230.
 at -e line 0
Compilation failed in require.
BEGIN failed--compilation aborted.
0
 
Lou1Author Commented:
kandura,
i guess i forgot to mention this but i already uninstalled ActiveState Perl. so it's just cygwin now.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.