DBD::Oracle + Cygwin: Undefined reference error during make

Yesterday I found myself in a position of having to re-master my computer – hence having to reinstall most of the applications including my trusty Cygwin – which always becomes somewhat of a headache when I reach the point of installing DBD::Oracle in it.

This time I got a undefined symbol error. A quick look in Google showed me that Erik Squires had the same exact problem. Lots of searching later, I find that Google can’t find a handy solution anywhere… So I send Erik an email asking about the solution and to my surprise, he answers only 1 (!!) minute after I click send. Talk about a fast reply!!

Hats off to Erik! You will find the solution here: http://cpae.typepad.com/capacity_planning_and_eng/

Hint: the oci.def that he mentions in his post is inside your DBD::Oracle build directory. Don’t get it confused with ocidef.h file in your $ORACLE_HOME/oci/include directory (that’s where I looked first).

I’m adding the error message below with a big SOLUTION header for any Googler out there having the same problem. No need to keep reading if the text above was enough to solve your problem.

Oracle 10g + DBD::Oracle + Cygwin issue

Make error:

————————————————————–

cp Oracle.pm blib/lib/DBD/Oracle.pm
cp oraperl.ph blib/lib/oraperl.ph
cp dbdimp.h blib/arch/auto/DBD/Oracle/dbdimp.h
cp ocitrace.h blib/arch/auto/DBD/Oracle/ocitrace.h
cp Oraperl.pm blib/lib/Oraperl.pm
cp Oracle.h blib/arch/auto/DBD/Oracle/Oracle.h
cp lib/DBD/Oracle/GetInfo.pm blib/lib/DBD/Oracle/GetInfo.pm
cp mk.pm blib/arch/auto/DBD/Oracle/mk.pm
/usr/bin/perl.exe -p -e "s/~DRIVER~/Oracle/g" /usr/lib/perl5/site_perl/
5.10/i686
-cygwin/auto/DBI/Driver.xst > Oracle.xsi
/usr/bin/perl.exe /usr/lib/perl5/5.10/ExtUtils/xsubpp  -typemap /usr/
lib/perl5/5
.10/ExtUtils/typemap -typemap typemap  Oracle.xs > Oracle.xsc && mv
Oracle.xsc O
racle.c
gcc -c  -IC:/oracle/product/10.2.0/client_1/oci/include -IC:/oracle/
product/10.2
.0/client_1/rdbms/demo -I/usr/lib/perl5/site_perl/5.10/i686-cygwin/
auto/DBI -DPE
RL_USE_SAFE_PUTENV -U__STRICT_ANSI__ -fno-strict-aliasing -pipe -I/usr/
local/inc
lude -DUSEIMPORTLIB -O3   -DVERSION="1.22" -DXS_VERSION="1.22"  "-
I/usr/lib/
perl5/5.10/i686-cygwin/CORE"  -Wall -Wno-comment -DUTF8_SUPPORT -
DNEW_OCI_INIT -
DORA_OCI_VERSION="10.2.0.1" Oracle.c
gcc -c  -IC:/oracle/product/10.2.0/client_1/oci/include -IC:/oracle/
product/10.2
.0/client_1/rdbms/demo -I/usr/lib/perl5/site_perl/5.10/i686-cygwin/
auto/DBI -DPE
RL_USE_SAFE_PUTENV -U__STRICT_ANSI__ -fno-strict-aliasing -pipe -I/usr/
local/inc
lude -DUSEIMPORTLIB -O3   -DVERSION="1.22" -DXS_VERSION="1.22"  "-
I/usr/lib/
perl5/5.10/i686-cygwin/CORE"  -Wall -Wno-comment -DUTF8_SUPPORT -
DNEW_OCI_INIT -
DORA_OCI_VERSION="10.2.0.1" dbdimp.c
dbdimp.c: In function `ora_db_login6':
dbdimp.c:450: warning: cast to pointer from integer of different size

{ A bunch more cast and int format warnings from oci8.c}

rm -f blib/arch/auto/DBD/Oracle/Oracle.dll
LD_RUN_PATH="C:/oracle/product/10.2.0/client_1/lib:C:/oracle/product/
10.2.0/clie
nt_1/rdbms/lib" g++  --shared  -Wl,--enable-auto-import -Wl,--export-
all-symbols
 -Wl,--stack,8388608 -Wl,--enable-auto-image-base -L/usr/local/lib
Oracle.o dbdi
mp.o oci8.o  -o blib/arch/auto/DBD/Oracle/Oracle.dll    
          /usr/lib/perl5/5.10/i686-cygwin/CORE/libperl.dll.a -L/
cygdrive/c/cpan/
5.10.0/build/DBD-Oracle-1.22 -loci      

Oracle.o:Oracle.c:(.text+0x6ba9): undefined reference to
`_OCILobGetChunkSize'
dbdimp.o:dbdimp.c:(.text+0x10e3): undefined reference to
`_OCINlsCharSetIdToName
'
dbdimp.o:dbdimp.c:(.text+0x110f): undefined reference to
`_OCINlsCharSetIdToName
'
collect2: ld returned 1 exit status
make: *** [blib/arch/auto/DBD/Oracle/Oracle.dll] Error 1

—————————————————————

!!! HERE IS THE SOLUTION !!!

Taken from http://cpae.typepad.com/capacity_planning_and_eng/

Thanks to Erik Squires!

[Quote]

undefined reference to `_OCILobGetChunkSize’

Several people helped me with a fix, but this text below is thanks to Jerry Reed. Thanks Jerry!

Please note this problem ONLY occurs under Windows. If you are running Perl under Unix/Linux/MacOS you should be fine.

Jerry Wrote:

The make of DBD Oracle builds an intermediate lib, liboci.a. Functions defined in this lib are somehow culled from the appropriate cygwin distro dll by the line that reads:

system(“dlltool –input-def oci.def –output-lib liboci.a”) at line 235 in Makefile.PL.

But oci.def lacks entries for the two undefined symbols –
_OCILobGetChunkSize

and

_OCINlsCharSetIdToName

(the later is named twice in the linker output).

Strip the leading underscore and insert them into a copy of oci.def. (I inserted them in alpha order, but I do not know if this is really required.)

rm, or use make clean to remove liboci.a and cause it to be rebuilt.

perl Makefile.PL
make

You should get no unresolved symbols now. You can check that liboci.a now contains the correct entries by:

nm liboci.a | egrep -i ‘(chunk|nls)’

[/Quote]

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.