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

Hi monks,

I'm having a tough time with a script i wrote that connects to a DB2 DB and does some stuff.

When i'm executing perl script.pl, i get an error :

ld.so.1: perl: fatal: relocation error: file /usr/perl5/site_perl/5.8. +4/sun4-solaris-64int/auto/DBD/DB2/DB2.so: symbol SQLAllocHandle: refe +renced symbol not found

Running perl in debug mode, i found out that it was the DBI->connect line that was failing :

my $dbh_DW = DBI->connect("DBI:DB2:Database=$DW_DB_NAME; Hostname=$DW_ +DB_HOST; Port=$DW_DB_PORT; Protocol=TCPIP; UID=$DW_DB_USER; PWD=$DW_D +B_PASS;",$DW_DB_USER,$DW_DB_PASS)

I've had to install the modules i needed manually (server is isolated) but i think I got them all

I'm using Solaris 10 64-bits. (using perl 5.8.4, DBI is 1.616 and DBD::DB2 is 1.82)

I've been working on this for a week, so please if anyone has an idea on why this error is happening, let me know!

Thanks!

Replies are listed 'Best First'.
Re: Problem Compiling under Solaris using DBI and DBD::DB2
by Eliya (Vicar) on Jan 13, 2012 at 20:29 UTC
    I've had to install the modules i needed manually

    Most likely, something went wrong in this step (i.e. during build and/or installation) — otherwise the symbol SQLAllocHandle could be resolved.

    It's hard to tell what went wrong, though, without seeing what exactly you did...   (post the commands you ran, together with their output (in particular any first errors) )

      Thanks for your answer. I don't have all the commands i did right here, but i kept what i did for DBD::DB2.

      STEP 1: root@whms17368 > /usr/perl5/5.8.4/bin/perlgcc Makefile.PL Configuring DBD::DB2... Remember to actually read the README and CAVEATS files! Using DB2 in "/home/db2inst1" System: perl5.008004 DBI1.616 sunos localhost 5.10 sun4u sparc SUNW,Ul +tra-2 sun4-solaris-64int dl_dlopen.xs Compiler: gcc -O2 -fno-strict-aliasing -D_LARGEFILE_SOURCE -D_FILE_OFF +SET_BITS=64 -D_TS_ERRNO Includes: -I"/home/db2inst1/include" -I"/usr/perl5/site_perl/5.8.4/su +n4-solaris-64int/auto/DBI" -I"/usr/perl5/5.8.4/lib/sun4-solaris-64int +/auto/DBI" -I"/usr/perl5/vendor_perl/5.8.4/sun4-solaris-64int/auto/DB +I" -I"/usr/perl5/site_perl/5.8.4/sun4-solaris-64int/auto/DBI" Libraries: -L/home/db2inst1/lib -ldb2 Note (probably harmless): No library found for -ldb2 Writing Makefile for DBD::DB2::Constants Writing Makefile for DBD::DB2 STEP2: root@whms17368 > make gcc -c -I"/home/db2inst1/include" -D_LARGEFILE_SOURCE -D_FILE_OFFSET +_BITS=64 -D_TS_ERRNO -O2 -fno-strict-aliasing -DVERSION=\"1.82\" +-DXS_VERSION=\"1.82\" -fPIC "-I/usr/perl5/5.8.4/lib/sun4-solaris-64in +t/CORE" Constants.c Running Mkbootstrap for DBD::DB2::Constants () chmod 644 Constants.bs rm -f ../blib/arch/auto/DBD/DB2/Constants/Constants.so LD_RUN_PATH="" gcc -G Constants.o -o ../blib/arch/auto/DBD/DB2/Const +ants/Constants.so chmod 755 ../blib/arch/auto/DBD/DB2/Constants/Constants.so cp Constants.bs ../blib/arch/auto/DBD/DB2/Constants/Constants.bs chmod 644 ../blib/arch/auto/DBD/DB2/Constants/Constants.bs gcc -c -I"/home/db2inst1/include" -I"/usr/perl5/site_perl/5.8.4/sun4- +solaris-64int/auto/DBI" -I"/usr/perl5/5.8.4/lib/sun4-solaris-64int/au +to/DBI" -I"/usr/perl5/vendor_perl/5.8.4/sun4-solaris-64int/auto/DBI" +-I"/usr/perl5/site_perl/5.8.4/sun4-solaris-64int/auto/DBI" -D_LARGEF +ILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_TS_ERRNO -O2 -fno-strict-aliasin +g -DVERSION=\"1.82\" -DXS_VERSION=\"1.82\" -fPIC "-I/usr/perl5/5. +8.4/lib/sun4-solaris-64int/CORE" -DDB2_CACHE_FIX DB2.c gcc -c -I"/home/db2inst1/include" -I"/usr/perl5/site_perl/5.8.4/sun4- +solaris-64int/auto/DBI" -I"/usr/perl5/5.8.4/lib/sun4-solaris-64int/au +to/DBI" -I"/usr/perl5/vendor_perl/5.8.4/sun4-solaris-64int/auto/DBI" +-I"/usr/perl5/site_perl/5.8.4/sun4-solaris-64int/auto/DBI" -D_LARGEF +ILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_TS_ERRNO -O2 -fno-strict-aliasin +g -DVERSION=\"1.82\" -DXS_VERSION=\"1.82\" -fPIC "-I/usr/perl5/5. +8.4/lib/sun4-solaris-64int/CORE" -DDB2_CACHE_FIX dbdimp.c dbdimp.c: In function `dbd_db_connect': dbdimp.c:314: warning: cast to pointer from integer of different size dbdimp.c:325: warning: cast to pointer from integer of different size dbdimp.c:336: warning: cast to pointer from integer of different size dbdimp.c: In function `db2_db_STORE_attrib': dbdimp.c:897: warning: cast to pointer from integer of different size dbdimp.c: In function `dbd_conn_opt': dbdimp.c:2482: warning: cast to pointer from integer of different size dbdimp.c: In function `db2_st_STORE_attrib': dbdimp.c:3209: warning: cast to pointer from integer of different size Running Mkbootstrap for DBD::DB2 () chmod 644 DB2.bs rm -f blib/arch/auto/DBD/DB2/DB2.so LD_RUN_PATH="" gcc -G DB2.o dbdimp.o -o blib/arch/auto/DBD/DB2/DB2. +so chmod 755 blib/arch/auto/DBD/DB2/DB2.so cp DB2.bs blib/arch/auto/DBD/DB2/DB2.bs chmod 644 blib/arch/auto/DBD/DB2/DB2.bs Manifying blib/man3/Bundle::DBD::DB2.3 Manifying blib/man3/DBD::DB2.3 root@whms17368 > STEP 3: root@whms17368 > make install Files found in blib/arch: installing files in blib/lib into architectu +re dependent library tree Writing /usr/perl5/site_perl/5.8.4/sun4-solaris-64int/auto/DBD/DB2/.pa +cklist Appending installation info to /usr/perl5/5.8.4/lib/sun4-solaris-64int +/perllocal.pod STEP 4: root@whms17368 > cd /export/home/ccmadm/CCM root@whms17368 > perl CCM.pl 2012/01/13 11:56:09 start test! ld.so.1: perl: fatal: relocation error: file /usr/perl5/site_perl/5.8. +4/sun4-solaris-64int/auto/DBD/DB2/DB2.so: symbol SQLAllocHandle: refe +renced symbol not found Killed
        Note (probably harmless): No library found for -ldb2

        This is most likely the problem (note that although it says "probably harmless", it definitely isn't, as this is the essential library here).

        When you see this message, the respective link instruction is removed from the list, which means the Perl binding .../DBD/DB2/DB2.so won't be linked against the library — resulting in the "symbol not found" error later at dynamic link time.

        In case you're sure you do have the right library in the specified place (/home/db2inst1/lib), the pragmatic way to resolve the issue (instead of trying to figure out why the above MakeMaker check failed) would be to manually rerun the final link command with the appropriate link instruction added, i.e. (from within the build directory)

        gcc -G DB2.o dbdimp.o -o blib/arch/auto/DBD/DB2/DB2.so -L/home/db2 +inst1/lib -ldb2 ^^^^^^^^^^ +^^^^^^^^^^^^^^^

        (if you get an error, you don't have the right library)

        Then run make test && make install, as usual.