Skip to contentSkip to conversation

why I cann't compile the program?

DISCUSSION Fangweiwei 2 participants 2 messages Nov 25, 2003 netfilter

lore
Share & tools
lore

Fangweiwei

author
#0 lore raw

Hello everyone!
I try to compile the following code,but it gives some msg to show something wrong?what should I do ?
------------------------------------------
/*
* This code is GPL.
*/
#include <linux/netfilter.h>
#include <libipq.h>
#include <stdio.h>

#define BUFSIZE 2048

static void die(struct ipq_handle *h)

{
        ipq_perror("passer");
        ipq_destroy_handle(h);
        exit(1);
}

int main(int argc, char **argv)

{
        int status;
        unsigned char buf[BUFSIZE];
        struct ipq_handle *h;

        h = ipq_create_handle(0, PF_INET);
        if (!h)
                die(h);

        status = ipq_set_mode(h, IPQ_COPY_PACKET, BUFSIZE);
        if (status < 0)
                die(h);

        do{
                status = ipq_read(h, buf, BUFSIZE, 0);
                if (status < 0)
                        die(h);

                switch (ipq_message_type(buf)) {
                        case NLMSG_ERROR:
                                fprintf(stderr, "Received error message %d\n",
                                        ipq_get_msgerr(buf));
                                break;

                        case IPQM_PACKET: {
                                ipq_packet_msg_t *m = ipq_get_packet(buf);

                                status = ipq_set_verdict(h, m->packet_id,
                                                         NF_ACCEPT, 0, NULL);
                                if (status < 0)
                                        die(h);
                                break;
                        }

                        default:
                                fprintf(stderr, "Unknown message type!\n");
                                break;
                }
        } while (1);

        ipq_destroy_handle(h);
        return 0;
}

----------------------------------------------
I try to compile it using: gcc test.c
but it gives me some msg as following:

/tmp/ccYcdyBh.o: In function `die':
/tmp/ccYcdyBh.o(.text+0xf): undefined reference to ipq_perror' /tmp/ccYcdyBh.o(.text+0x1d): undefined reference to ipq_destroy_handle' /tmp/ccYcdyBh.o: In function `main':
/tmp/ccYcdyBh.o(.text+0x41): undefined reference to ipq_create_handle' /tmp/ccYcdyBh.o(.text+0x7b): undefined reference to ipq_set_mode' /tmp/ccYcdyBh.o(.text+0xb5): undefined reference to ipq_read' /tmp/ccYcdyBh.o(.text+0xe3): undefined reference to ipq_message_type' /tmp/ccYcdyBh.o(.text+0x12a): undefined reference to ipq_get_msgerr' /tmp/ccYcdyBh.o(.text+0x157): undefined reference to ipq_get_packet' /tmp/ccYcdyBh.o(.text+0x17e): undefined reference to `ipq_set_verdict'
collect2: ld returned 1 exit status

----------------------------------------------

can you help me? thanks a lot.

        Fangweiwei
        [email protected]
          2003-11-25

#1 lore raw

Hello,

Quoted 4 lines · Fangweiwei

----------------------------------------------
I try to compile it using: gcc test.c

try compiling it with

gcc -o test test.c -lipq

This will link it with the ipq library (which you of course must have installed).

Quoted 15 lines

but it gives me some msg as following:

/tmp/ccYcdyBh.o: In function `die':
/tmp/ccYcdyBh.o(.text+0xf): undefined reference to ipq_perror' /tmp/ccYcdyBh.o(.text+0x1d): undefined reference to ipq_destroy_handle' /tmp/ccYcdyBh.o: In function `main':
/tmp/ccYcdyBh.o(.text+0x41): undefined reference to ipq_create_handle' /tmp/ccYcdyBh.o(.text+0x7b): undefined reference to ipq_set_mode' /tmp/ccYcdyBh.o(.text+0xb5): undefined reference to ipq_read' /tmp/ccYcdyBh.o(.text+0xe3): undefined reference to ipq_message_type' /tmp/ccYcdyBh.o(.text+0x12a): undefined reference to ipq_get_msgerr' /tmp/ccYcdyBh.o(.text+0x157): undefined reference to ipq_get_packet' /tmp/ccYcdyBh.o(.text+0x17e): undefined reference to `ipq_set_verdict'
collect2: ld returned 1 exit status

Quoted 8 lines

----------------------------------------------

can you help me? thanks a lot.

        Fangweiwei
        [email protected]
          2003-11-25

Sven