LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 06-22-2004, 06:00 PM   #1
inthefuture
LQ Newbie
 
Registered: Jun 2004
Posts: 23

Rep: Reputation: 15
Lightbulb Can't access libpcap library :(


Hey

I am so new to linux that every step I take gives me so much trouble. Hopefully I can find good solution here...

The problem should be simple for experts I guess:

I use Knoppix 3.4 to compile libpcap 0.8.3. Suppose I get a libpcap library, which will be used by another program, named as "weplab".

./configure and make goes well except Knoppix doesn't allow to write on /usr folder (read-only system). So I let the files go to /tmp by using

./configure --prefix=/usr && make && make install

I checked /tmp and /tmp/lib/, libpcap.a, pcap.h and other files are there. But when I configure weplab, it doesn't recognize the path. Then I copied everything into weplab folder. Still, it gives error like:

undefined reference pcap_close
undefined reference pcap_......

Sorry for my lengthy description. My question is how can I let the weplab program to recognize the library? ( I suppose libpcap.a is the library and has everything I need). I checked one of the files that uses the reference, it includes "pcap.h" in the header and directly call the function. I don't know how to modify it.

Please anybody help me, I really need to get this down as soon as possible.

Many many thanks!
 
Old 06-22-2004, 06:06 PM   #2
avarus
Member
 
Registered: Apr 2004
Location: Oxford, UK
Distribution: Ubuntu, Debian, various
Posts: 230
Blog Entries: 5

Rep: Reputation: 32
Hi,

You need to tell gcc where to find the library files. You can use the -L flag for this:

gcc -L/tmp/lib ...

If weplab is being built using automake, you should be able to add this by setting CFLAGS :

export CFLAGS='-L/tmp/lib'

Then try the build again.

Is that any help?

TIM
 
Old 06-22-2004, 06:49 PM   #3
inthefuture
LQ Newbie
 
Registered: Jun 2004
Posts: 23

Original Poster
Rep: Reputation: 15
Thanks for the reply.

I tried: export CFLAGS='-L/tmp/lib' && make OR export CFLAGS='-L/tmp/lib' && ./configure && make

but still had the problem. Here are part of the error messages:

analpfile.o(.text+0xa6): In function `AnalyzePcapFile':
: undefined reference to `pcap_file'
analpfile.o(.text+0x110): In function `AnalyzePcapFile':
: undefined reference to `pcap_next'
capture.o(.text+0x157): In function `callbackWeakPackets':
: undefined reference to `pcap_dump'
.....

From what I searched, /tmp/lib/libpcap should be the library function of libpcap. If compilation of libpcap goes right, what else could the problem be???
 
Old 06-22-2004, 11:24 PM   #4
infamous41md
Member
 
Registered: Mar 2003
Posts: 804

Rep: Reputation: 30
try passing the shared library file directly on the command line.
 
Old 06-23-2004, 01:46 AM   #5
inthefuture
LQ Newbie
 
Registered: Jun 2004
Posts: 23

Original Poster
Rep: Reputation: 15
would you please give me more details about how to pass the shared library on the command line? Sorry I am a very new beginner, this thing doesn't look easy to me.

I changed parameter CFLAGS in Makefile, it still didn't work. And the last time I got an error message "-lpcap not found". But I don't know where is lpcap located, it's not in any .h file nor libpcap.a
 
Old 06-23-2004, 01:27 PM   #6
avarus
Member
 
Registered: Apr 2004
Location: Oxford, UK
Distribution: Ubuntu, Debian, various
Posts: 230
Blog Entries: 5

Rep: Reputation: 32
Hi,

To summarise:

Passing the parameter '-lpcap' to gcc tells it to look for and link the file 'libpcap.a'.
gcc will look for this file in its search path.
The search path will include any directories specified with the -L flag
You have inserted this flag into the $CFLAGS variable, so it should be picked up

So it is a mystery to me why this is not working. You will have to get hold of the actual gcc command which is being run and attempt to decipher it then run it manually - I'm afraid the small portion of the error message you have posted does not tell me much other than that the linking failed.

Don't wish to be rude but maybe trying to compile some code on a read-only system when you don't know much about Linux or C or autoconf and need it done in a hurry was doomed to failure? Having said that - don't give up now!

TIM
 
Old 06-23-2004, 03:12 PM   #7
inthefuture
LQ Newbie
 
Registered: Jun 2004
Posts: 23

Original Poster
Rep: Reputation: 15
inthefuture

Hi TIM:

It's very nice of you trying to help me out. I know it is a little too unreasonable, but when ppl gave me work, I can't just say "I don't know" or I will loose it.

I wanted to try other linuxOS such as SUSE and RH, but I just can't figure out how to set up wireless card. After failed many times, I thought Knoppix is the easiest way for beginner. School doesn't teach linux and I haven't tried any other wireless related programs before...

Anyway, I will read the source code and try to figure out from there. Just want to thank those who provided help, it is really great that sb. replies you when you are desparate.
 
Old 06-23-2004, 05:34 PM   #8
infamous41md
Member
 
Registered: Mar 2003
Posts: 804

Rep: Reputation: 30
pass the library on command line means, if the name of the shared library file created by the make'ing of libpcap is called libpcap.so, then do this:

gcc my_prog.c libpcap.so
 
Old 06-24-2004, 06:30 PM   #9
avarus
Member
 
Registered: Apr 2004
Location: Oxford, UK
Distribution: Ubuntu, Debian, various
Posts: 230
Blog Entries: 5

Rep: Reputation: 32
Ah, the joys of wireless configuration. It took me about a month to get my network sorted and I administer Linux for a living. :-/ All I would say is there is a lot of good info in the FAQs on this site.

As Infamous says, you definitely need to run gcc manually, but you will need to know the failed command. The make process should show all the commands as it runs, so find the failing command and run it. It should then be easy to force it to link the right files.

Happy hacking,

TIM
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
JAVA JNI program to access shared library sabliny Programming 3 11-17-2005 06:13 PM
howto compile bin with my library using all-static and shared linked standart library stpg Programming 4 06-29-2004 05:20 AM
Can't Access Libpcap Library with Knoppix inthefuture Linux - Software 2 06-23-2004 08:39 AM
UnsatisfiedLinkError on JNI access to Shared Library Kavinjka Linux - Software 1 08-25-2003 07:08 AM
libpcap oulevon Linux - General 1 09-25-2001 10:06 AM


All times are GMT -5. The time now is 01:19 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration