Can't access libpcap library :(
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!
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 :
Then try the build again.
Is that any help?
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???
try passing the shared library file directly on the command line.
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
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!
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.
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
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.
|All times are GMT -5. The time now is 06:27 AM.|