Welcome to Linux Forums! With a comprehensive Linux Forum, information on various types of Linux software and many Linux Reviews articles, we have all the knowledge you need a click away, or accessible via our knowledgeable members.
Write an article for LinuxForums Today! Win Great Prizes!
Find the answer to your Linux question:
New to Linux Forums? Register here for free!
    Linux Forums > GNU Linux Zone > Linux Programming & Scripting > Libpcap problem !!! Urgent

Forgot Password?
 Linux Programming & Scripting   C, Perl, PHP, Bash Scripts, anything programming or script related post in here!

Site Navigation
Linux Articles
Linux Forums
Linux Downloads
Linux Hosting
Free Magazines
Job Board
IRC Chat
RSS Feeds
Linux Forum Topics
Linux Forums
Your Distro
Linux Resources
GNU Linux Zone
The Community
Reply
 
Thread Tools Display Modes
Old 05-15-2009   #1 (permalink)
Just Joined!
 
Join Date: May 2009
Posts: 1
Libpcap problem !!! Urgent

hi .. im having trouble writing a simple snippet using pcap.h

even when i try to compile a simple code like :

#include <stdio.h>
#include <pcap.h>

int main(int argc, char *argv[])
{
char *dev, errbuf[PCAP_ERRBUF_SIZE];
dev = pcap_lookupdev(errbuf);

if (dev == NULL) {
fprintf(stderr, "Couldn't find default device: %s\n", errbuf);
return(2);
}
printf("Device: %s\n", dev);
return(0);
}

.. i get an error saying undefined reference to "pcap_lookupdev".

Even if i try a longer code .. i get the same error for each of the pcaps functionalities i have used (pcap_open_live, pcap_loop, etc).

I downloaded the pcap folder from tcpdump.org and pasted it in my usr/include. All include files are in order as far as i know.

I have 2 days left to my project deadline .. someone please help .. thanks alot .. cheers
abhisheksikka is offline  



Reply With Quote
Old 05-15-2009   #2 (permalink)
Just Joined!
 
Join Date: May 2009
Posts: 5
This error seems to be coming because linker is unable to find the library. After downloading and unzippping, you should have got a libpcap.so file in the same folder.

I'd suggest you two things to do:
1. export LD_LIBRARY_PATH=absolute_path_of_pcap_lib:$LD_LIBR ARY_PATH

OR

2. In the compilation command, add "-lpcap" at the end of command.

HTH,
Bluehive
bluehive is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Free Magazines
Run Your Own Web Server Using Linux & Apache - Free 191 Page Preview
Learn about everything you'll need to build and maintain your Linux servers, and to deploy Web applications to them.
subscribe
Open Source Security Myths Dispelled
Dispel the five major myths surrounding Open Source Security and gain the tools necessary to make a truly informed decision for your IT organization
subscribe
InformationWeek
InformationWeek is the only newsweekly you'll need to stay on top of the latest developments in information technology.
subscribe



All times are GMT. The time now is 04:38 PM.






© 2000 - - All Rights Reserved - Property of  MAS Media

Content Relevant URLs by vBSEO 3.3.1