LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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 11-30-2003, 08:13 PM   #1
enjoyzj
LQ Newbie
 
Registered: Nov 2003
Posts: 29

Rep: Reputation: 15
problem with trying the libipq example code


I am new to netfilter and even linux. I just wish to try the example code in the man page of libipq (I saved it as test.c and have compiled it to test.o). But when I make it: #cc test.o -o test, the following errors showed up:

[root@kite1 netfilter]# cc test.o -o test
test.o(.text+0xf): In function `die':
: undefined reference to `ipq_perror'
test.o(.text+0x1d): In function `die':
: undefined reference to `ipq_destroy_handle'
test.o(.text+0x49): In function `main':
: undefined reference to `ipq_create_handle'
test.o(.text+0x81): In function `main':
: undefined reference to `ipq_set_mode'
test.o(.text+0xb8): In function `main':
: undefined reference to `ipq_read'
test.o(.text+0xe4): In function `main':
: undefined reference to `ipq_message_type'
test.o(.text+0x116): In function `main':
: undefined reference to `ipq_get_msgerr'
test.o(.text+0x141): In function `main':
: undefined reference to `ipq_get_packet'
test.o(.text+0x18c): In function `main':
: undefined reference to `ipq_set_verdict'
test.o(.text+0x1ce): In function `main':
: undefined reference to `ipq_set_verdict'
collect2: ld returned 1 exit status

I have installed iptables-1.2.9 following the instructions. Does it mean I have to link 'test.o' with another file (???.o or ???.so)? Thank you in advance!

Jee
 
Old 12-03-2003, 04:30 AM   #2
Majjj
LQ Newbie
 
Registered: Sep 2003
Location: Hyderabad
Distribution: Fedora Core 2
Posts: 10

Rep: Reputation: 0
Try this...

cc test.o -o test -I /usr/include/libipq -lipq

bye
Majjj
 
Old 12-03-2003, 04:48 PM   #3
enjoyzj
LQ Newbie
 
Registered: Nov 2003
Posts: 29

Original Poster
Rep: Reputation: 15
Thanks a lot!
I tried cc test.o -o test -lipq
then it works!
 
Old 12-07-2003, 06:14 PM   #4
enjoyzj
LQ Newbie
 
Registered: Nov 2003
Posts: 29

Original Poster
Rep: Reputation: 15
Oh, this time I try to compile a C++ file (test.cpp), whose content is almost the same with that in test.c. When I use 'test.o -o test -lipq', the result shows as if there were no '-lipq'. What shall I do to compile and link a C++ file? Thanks a lot!
 
Old 12-07-2003, 07:41 PM   #5
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
try
extern "C"
{
#include <ipq.h>
}

or something like that :) ... I haven't compiled
C++ against C in ages, so bear with me.

The problem your facing is the fact that
name mangling in C and C++ differ, and C
functions you call from C++ need to be
declared as extern "C" ... not sure whether
it will take the entire include like that, or
whether you'll have to make a wrapper
within the include file.


Cheers,
Tink
 
  


Reply



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
Kernel AODV and libipq mahbub_bd Linux - Networking 1 05-19-2011 04:24 AM
small syntax problem with C code (implemented in Code Composer Studio) illiniguy3043 Programming 6 01-07-2008 02:14 AM
How to retrieve an sk_buff from libipq netfunk Linux - Networking 2 03-20-2006 04:16 AM
compile/linker problem with simple libipq code TheLinuxDuck Programming 7 05-06-2005 01:28 PM
packet reordering and delay using libipq shinkm Linux - Networking 0 09-08-2004 12:22 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:41 AM.

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
Open Source Consulting | Domain Registration