tcpdump mailing list archives

Re: Libpcap as shared object


From: Guy Harris <guy () netapp com>
Date: Wed, 30 Apr 2003 17:04:59 -0700

On Wed, Apr 30, 2003 at 12:40:38AM +0200, Werner Schalk wrote:
this maybe a dump question but I did not found
any answer to it: How can I compile libpcap with
a shared object (libpcap.so) file?

That depends on the OS on which you're running.

I have successfully
compiled and installed it but it has only created
an .a file.

Correct.  Given that it does depend on the OS on which you're running,
the sort of patches people have been contributing to build a shared
libpcap, which assume you're using the GNU linker (probably because the
contributors are using Linux or BSD and thus are using the GNU linker)
and just use the GNU linker flags, are not acceptable and have not been
applied.  A patch that uses libtool would be the best answer here.

I have tried this command to create a shared object manually:

ld -G -o libpcap.so -lnsl -lresolv -lc -z allextract

I infer from the command line you're using (because you're using "-G")
that you're running on some System V Release 4-ish system.

(If so, and if it's Solaris, you might want to link with "-lsocket"
before "-lnsl", as "man getservbyname", for example, mentions
"-lsocket", and libpcap uses "getservbyname()".  I can't speak for other
SVR4 derivatives.)

This works but the shared object is not accepted by
the apps using libpcap.

"Not accepted" in what sense?

Note that if the .so file isn't in one of the standard libraries
searched for by the run-time linker, then, at least on Solaris, you
should probably not only specify a "-L" flag when linking the
application, specifying the directory in which the .so is installed, but
also specify a "-R" flag, specifying the same directory, so not only
will the linker search that directory, so will the run-time linker.
-
This is the TCPDUMP workers list. It is archived at
http://www.tcpdump.org/lists/workers/index.html
To unsubscribe use mailto:tcpdump-workers-request () tcpdump org?body=unsubscribe


Current thread: