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

Hi I have been trying for 2 days to install and use Net::Pcap, but regardless of what I try I get the following error :
ld.so.1: perl-static: fatal: relocation error: file /app/orc/mdscripts +/PerlModules/lib/auto/Net/Pcap/Pcap.so: symbol pcap_open_live: refere +nced symbol not found Killed
I am on a Solaris10 x86 machine :
bash-3.00$ uname -a SunOS enocln99 5.10 Generic_137112-07 i86pc i386 i86pc bash-3.00$
using ActiveState Perl 5.10.0.1004 :
bash-3.00$ perl -V Set up gcc environment - 3.4.3 (csl-sol210-3_4-branch+sol_rpath) Summary of my perl5 (revision 5 version 10 subversion 0) configuration +: Platform: osname=solaris, osvers=2.10, archname=x86-solaris-thread-multi uname='sunos ginsu 5.10 generic_125101-10 i86pc i386 i86pc ' config_args='-ders -Dcc=cc -Dusethreads -Duseithreads -Ud_sigsetjm +p -Uinstallusrbinperl -Ulocincpth= -Uloclibpth= -Ud_strerror_r -Ud_si +gnbit -Accflags=-DUSE_SITECUSTOMIZE -Duselargefiles -Accflags=-DPRIVL +IB_LAST_IN_INC -Dprefix=/opt/ActivePerl-5.10 -Dprivlib=/opt/ActivePer +l-5.10/lib -Darchlib=/opt/ActivePerl-5.10/lib -Dsiteprefix=/opt/Activ +ePerl-5.10/site -Dsitelib=/opt/ActivePerl-5.10/site/lib -Dsitearch=/o +pt/ActivePerl-5.10/site/lib -Dsed=/usr/bin/sed -Duseshrplib -Dcf_by=A +ctiveState -Dcf_email=support@ActiveState.com' hint=recommended, useposix=true, d_sigaction=define useithreads=define, usemultiplicity=define useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=und +ef use64bitint=undef, use64bitall=undef, uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='gcc', ccflags ='-D_REENTRANT -DUSE_SITECUSTOMIZE -DPRIVLIB_LAS +T_IN_INC -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DPERL_USE_SAFE_P +UTENV -fno-strict-aliasing -pipe', optimize='-O', cppflags='-D_REENTRANT -DUSE_SITECUSTOMIZE -DPRIVLIB_LAST_IN_INC - +fno-strict-aliasing -pipe' ccversion='', gccversion='3.4.3 (csl-sol210-3_4-branch+sol_rpath)' +, gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=1 +2 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', + lseeksize=8 alignbytes=4, prototype=define Linker and Libraries: ld='gcc', ldflags =' -L/usr/lib -L/usr/ccs/lib -L/opt/SUNWspro/pro +d/lib -L/lib ' libpth=/usr/lib /usr/ccs/lib /opt/SUNWspro/prod/lib /lib libs=-lsocket -lnsl -ldl -lm -lpthread -lc perllibs=-lsocket -lnsl -ldl -lm -lpthread -lc libc=, so=so, useshrplib=true, libperl=libperl.so gnulibc_version='' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' -R /op +t/ActivePerl-5.10/lib/CORE' cccdlflags='-fPIC', lddlflags='-G -L/usr/lib -L/usr/ccs/lib -L/opt +/SUNWspro/prod/lib -L/lib' Characteristics of this binary (from libperl): Compile-time options: MULTIPLICITY PERL_DONT_CREATE_GVSV PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP PERL_USE_SAFE_PUTENV USE_ITHREADS USE_LARGE_FI +LES USE_PERLIO USE_REENTRANT_API USE_SITECUSTOMIZE Locally applied patches: ActivePerl Build 1004 [287188] 33741 avoids segfaults invoking S_raise_signal() (on Linux) 32809 Load 'loadable object' with non-default file extension 32728 64-bit fix for Time::Local Built under solaris Compiled at Sep 3 2008 11:06:56 %ENV: PERL5LIB="/app/orc/mdscripts/PerlModules/lib" @INC: /app/orc/mdscripts/PerlModules/lib /opt/ActivePerl-5.10/site/lib /opt/ActivePerl-5.10/lib . bash-3.00$
I have installed the libpcap library from SunFreeware.com, which has both forms of the library :
bash-3.00$ find /usr/local -name \*cap\*|egrep -v share /usr/local/bin/captoinfo /usr/local/bin/infotocap /usr/local/bin/pcap-config /usr/local/doc/ncurses/doc/html/ada/terminal_interface-curses-termcap_ +_adb.htm /usr/local/doc/ncurses/doc/html/ada/terminal_interface-curses-termcap_ +_ads.htm /usr/local/doc/ncurses/doc/html/man/captoinfo.1m.html /usr/local/doc/ncurses/doc/html/man/curs_termcap.3x.html /usr/local/doc/ncurses/doc/html/man/infotocap.1m.html /usr/local/doc/libpcap /usr/local/man/man1/captoinfo.1m /usr/local/man/man1/infotocap.1m /usr/local/man/man3/curs_termcap.3x /usr/local/lib/libpcap.a /usr/local/lib/libpcap.so /usr/local/include/ncurses/termcap.h /usr/local/include/pcap /usr/local/include/pcap/pcap.h /usr/local/include/pcap-bpf.h /usr/local/include/pcap-namedb.h /usr/local/include/pcap.h bash-3.00$
Here's the compile of Net::Pcap(install steps not shown) :
bash-3.00$ perl Makefile.PL PREFIX=~/mdscripts/PerlModules Set up gcc environment - 3.4.3 (csl-sol210-3_4-branch+sol_rpath) looking for -lpcap... yes checking for pcap_lib_version() in -lpcap... no - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - You appear to have an old version of the pcap library. This module need a recent version of the pcap library in order to prov +ide access to all its features. You can still compile it with your old pca +p library but some functions won't be available, and trying to use them +in Perl programs will generate errors. Programs only using the old functi +ons should perform as previously. If not, don't hesitate to fill a bug. You can get the latest sources of the pcap library at http://www.tcpdu +mp.org/ If you install the pcap library using a system package, make sure to a +lso install the corresponding -devel package, which contains the C headers + needed to compile this module. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - trying to detect actually available functions... ok Checking if your kit is complete... Looks good Note (probably harmless): No library found for -lpcap Writing Makefile for Net::Pcap bash-3.00$ bash-3.00$ bash-3.00$ make cp Pcap.pm blib/lib/Net/Pcap.pm AutoSplitting blib/lib/Net/Pcap.pm (blib/lib/auto/Net/Pcap) /opt/ActivePerl-5.10/bin/perl /opt/ActivePerl-5.10/lib/ExtUtils/xsubpp + -typemap /opt/ActivePerl-5.10/lib/ExtUtils/typemap -typemap typemap + Pcap.xs > Pcap.xsc && mv Pcap.xsc Pcap.c gcc -c -Wall -O -DVERSION=\"0.14\" -DXS_VERSION=\"0.14\" -fPIC "-I +/opt/ActivePerl-5.10/lib/CORE" -DHAVE_BLANK -DHAVE_PCAP_ACTIVATE -DH +AVE_PCAP_BREAKLOOP -DHAVE_PCAP_CAN_SET_RFMON -DHAVE_PCAP_COMPILE_NOPC +AP -DHAVE_PCAP_CREATE -DHAVE_PCAP_DATALINK_EXT -DHAVE_PCAP_DATALINK_N +AME_TO_VAL -DHAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION -DHAVE_PCAP_DATALI +NK_VAL_TO_NAME -DHAVE_PCAP_DUMP_FILE -DHAVE_PCAP_DUMP_FLUSH -DHAVE_PC +AP_DUMP_FOPEN -DHAVE_PCAP_DUMP_FTELL -DHAVE_PCAP_FINDALLDEVS -DHAVE_P +CAP_FOPEN_OFFLINE -DHAVE_PCAP_FREEALLDEVS -DHAVE_PCAP_FREE_DATALINKS +-DHAVE_PCAP_GETNONBLOCK -DHAVE_PCAP_GET_SELECTABLE_FD -DHAVE_PCAP_INJ +ECT -DHAVE_PCAP_LIB_VERSION -DHAVE_PCAP_LIST_DATALINKS -DHAVE_PCAP_NE +XT_EX -DHAVE_PCAP_OFFLINE_FILTER -DHAVE_PCAP_OPEN_DEAD -DHAVE_PCAP_SE +NDPACKET -DHAVE_PCAP_SETDIRECTION -DHAVE_PCAP_SETNONBLOCK -DHAVE_PCAP +_SET_BUFFER_SIZE -DHAVE_PCAP_SET_DATALINK -DHAVE_PCAP_SET_PROMISC -DH +AVE_PCAP_SET_RFMON -DHAVE_PCAP_SET_SNAPLEN -DHAVE_PCAP_SET_TIMEOUT -D +HAVE_PCAP_STATUSTOSTR Pcap.c In file included from Pcap.xs:43: stubs.inc:322:2: warning: #warning "the function pcap_createsrcstr() i +s not available" stubs.inc:337:2: warning: #warning "the function pcap_parsesrcstr() is + not available" stubs.inc:352:2: warning: #warning "the function pcap_open() is not av +ailable" stubs.inc:373:2: warning: #warning "the function pcap_setbuff() is not + available" stubs.inc:388:2: warning: #warning "the function pcap_setuserbuffer() +is not available" stubs.inc:403:2: warning: #warning "the function pcap_setmode() is not + available" stubs.inc:418:2: warning: #warning "the function pcap_setmintocopy() i +s not available" stubs.inc:433:2: warning: #warning "the function pcap_sendqueue_alloc( +) is not available" stubs.inc:455:2: warning: #warning "the function pcap_sendqueue_destro +y() is not available" stubs.inc:469:2: warning: #warning "the function pcap_sendqueue_queue( +) is not available" stubs.inc:484:2: warning: #warning "the function pcap_sendqueue_transm +it() is not available" stubs.inc:499:2: warning: #warning "the function pcap_event() is not a +vailable" stubs.inc:514:2: warning: #warning "the function pcap_setsampling() is + not available" Pcap.c: In function `XS_Net__Pcap_strerror': Pcap.c:1574: warning: assignment discards qualifiers from pointer targ +et type Running Mkbootstrap for Net::Pcap () chmod 644 Pcap.bs rm -f blib/arch/auto/Net/Pcap/Pcap.so gcc -G -L/usr/local/lib -L/usr/lib -L/usr/ccs/lib -L/opt/SUNWspro/pro +d/lib -L/lib Pcap.o -o blib/arch/auto/Net/Pcap/Pcap.so \ \ chmod 755 blib/arch/auto/Net/Pcap/Pcap.so cp Pcap.bs blib/arch/auto/Net/Pcap/Pcap.bs chmod 644 blib/arch/auto/Net/Pcap/Pcap.bs cp bin/pcapinfo blib/script/pcapinfo /opt/ActivePerl-5.10/bin/perl "-MExtUtils::MY" -e "MY->fixin(shift)" b +lib/script/pcapinfo Set up gcc environment - 3.4.3 (csl-sol210-3_4-branch+sol_rpath) Manifying blib/man1/pcapinfo.1 Manifying blib/man3/Net::Pcap.3 bash-3.00$ echo $? 0 bash-3.00$ bash-3.00$
So everything looks like it's gone ok, but I get the error previously mentioned :
ld.so.1: perl-static: fatal: relocation error: file /app/orc/mdscripts +/PerlModules/lib/auto/Net/Pcap/Pcap.so: symbol pcap_open_live: refere +nced symbol not found Killed
I'm at my wit's end. I have tried : But whatever I do it doesn't work. Any ideas ??

Replies are listed 'Best First'.
Re: Net::Pcap + Solaris10 x86 : runtime error madness
by jettero (Monsignor) on May 27, 2009 at 12:40 UTC
    It seems to be compiling using the /usr/local/lib version. But I think the bootloader is picking up the older version (or a version otherwise without the pcap_open_live symbol). See if you can change your lib load order to pick up the /usr/local/lib (presumably the version you compiled yourself) first.

    That, or see if you can get Net::Pcap to compile statically. I had some luck with this while working with disagreeable libs in win32:

    perl Makefile.PL LINKTYPE=static # recommended

    (Quoted from ExtUtils::MakeMaker.)

    UPDATE/response: maybe, maybe not. Suppose there's shared versions of the lib hanging around. It's better to make sure /usr/local/lib is at the top of the libpath and to use LINKTYPE=static to make sure you're pulling in a .a instead of a .so

    -Paul

      You only need to compile libpcap statically
Re: Net::Pcap + Solaris10 x86 : runtime error madness
by almut (Canon) on May 27, 2009 at 15:34 UTC
    gcc -G -L/usr/local/lib -L/usr/lib -L/usr/ccs/lib -L/opt/SUNWspro/pro +d/lib -L/lib Pcap.o -o blib/arch/auto/Net/Pcap/Pcap.so \ \

    This shows that Pcap.so hasn't actually been linked against libpcap (no -lpcap on that command line, for whatever reason...).

    In case you don't really want to solve the underlying problem with the older version apparently being found, no proper Makefile being written etc., but would rather just want to get it working this time for this build attempt, you could try to manually issue the proper link command (from the directory where Pcap.o lives):

    gcc -G Pcap.o -o blib/arch/auto/Net/Pcap/Pcap.so /usr/local/lib/libpca +p.a

    (and then run make test; make install)

      I did the standard build steps for Net::Pcap and then issued this command :
      gcc -L/usr/lib -L/usr/ccs/lib -L/opt/SUNWspro/prod/lib -L/lib -L/app/ +orc/mdscripts/Binaries/lib -G Pcap.o -o blib/arch/auto/Net/Pcap/Pcap +.so /app/orc/mdscripts/Binaries/lib/libpcap.a
      then I copied the resultant shared library into place and it works a dream. Thankyou very much indeed, you guys are the BEST !!