Re: Documentation oddity.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Duncan,

Thanks for the reply.

On Tue, 11 Mar 2025, Duncan Roe wrote:
On Mon, Mar 10, 2025 at 06:00:40PM +0000, G.W. Haywood wrote:
...
In the docs at

https://www.netfilter.org/projects/libnetfilter_queue/doxygen/html/

there is given a command to compile the sample code in nf-queue.c.

The command given is

gcc -g3 -ggdb -Wall -lmnl -lnetfilter_queue -o nf-queue nf-queue.c

Here, and I suspect almost everywhere else, that doesn't work.

Works here with gcc versions 11.2.0 and 14.2.0.

Debian 11, gcc version 10.2.1-6 here.

Should the command not be something more like the one below?

gcc -o nf-queue nf-queue.c -g3 -ggdb -Wall -lmnl -lnetfilter_queue

gcc doesn't care, but the conventional order for command arguments is option
args first, as in the docs.

That's what I'd always thought - until I tried to do what it said
there, searched stackoverflow for similar issues, and found them. :/

The -ggdb argument is obsolete and may be slated for removal. Can you please try
this:

gcc -g3 -gdwarf-4 -Wall -lmnl -lnetfilter_queue -o nf-queue nf-queue.c

Same problem exactly.

If it still fails for you, please let me know at least 2 things:

1. What is the error message

8<----------------------------------------------------------------------
$ gcc -g3 -gdwarf-4 -Wall -lmnl -lnetfilter_queue -o nf-queue nf-queue.c
/usr/bin/ld: /tmp/ccbLJv89.o: in function `nfq_send_verdict':
/home/ged/nf-queue.c:30: undefined reference to `nfq_nlmsg_put'
/usr/bin/ld: /home/ged/nf-queue.c:31: undefined reference to `nfq_nlmsg_verdict_put'
/usr/bin/ld: /home/ged/nf-queue.c:34: undefined reference to `mnl_attr_nest_start'
/usr/bin/ld: /home/ged/nf-queue.c:37: undefined reference to `mnl_attr_put_u32'
/usr/bin/ld: /home/ged/nf-queue.c:41: undefined reference to `mnl_attr_nest_end'
/usr/bin/ld: /home/ged/nf-queue.c:43: undefined reference to `mnl_socket_sendto'
/usr/bin/ld: /tmp/ccbLJv89.o: in function `queue_cb':
/home/ged/nf-queue.c:60: undefined reference to `nfq_nlmsg_parse'
/usr/bin/ld: /home/ged/nf-queue.c:65: undefined reference to `mnl_nlmsg_get_payload'
/usr/bin/ld: /home/ged/nf-queue.c:75: undefined reference to `mnl_attr_get_payload'
/usr/bin/ld: /home/ged/nf-queue.c:78: undefined reference to `mnl_attr_get_payload_len'
/usr/bin/ld: /home/ged/nf-queue.c:93: undefined reference to `mnl_attr_get_u32'
/usr/bin/ld: /home/ged/nf-queue.c:97: undefined reference to `mnl_attr_get_u32'
/usr/bin/ld: /home/ged/nf-queue.c:111: undefined reference to `mnl_attr_get_payload'
/usr/bin/ld: /tmp/ccbLJv89.o: in function `main':
/home/ged/nf-queue.c:162: undefined reference to `mnl_socket_open'
/usr/bin/ld: /home/ged/nf-queue.c:168: undefined reference to `mnl_socket_bind'
/usr/bin/ld: /home/ged/nf-queue.c:172: undefined reference to `mnl_socket_get_portid'
/usr/bin/ld: /home/ged/nf-queue.c:184: undefined reference to `nfq_nlmsg_put'
/usr/bin/ld: /home/ged/nf-queue.c:185: undefined reference to `nfq_nlmsg_cfg_put_cmd'
/usr/bin/ld: /home/ged/nf-queue.c:187: undefined reference to `mnl_socket_sendto'
/usr/bin/ld: /home/ged/nf-queue.c:195: undefined reference to `nfq_nlmsg_put'
/usr/bin/ld: /home/ged/nf-queue.c:196: undefined reference to `nfq_nlmsg_cfg_put_params'
/usr/bin/ld: /home/ged/nf-queue.c:198: undefined reference to `mnl_attr_put_u32'
/usr/bin/ld: /home/ged/nf-queue.c:199: undefined reference to `mnl_attr_put_u32'
/usr/bin/ld: /home/ged/nf-queue.c:201: undefined reference to `mnl_socket_sendto'
/usr/bin/ld: /home/ged/nf-queue.c:211: undefined reference to `mnl_socket_setsockopt'
/usr/bin/ld: /home/ged/nf-queue.c:217: undefined reference to `mnl_socket_recvfrom'
/usr/bin/ld: /home/ged/nf-queue.c:223: undefined reference to `mnl_cb_run'
collect2: error: ld returned 1 exit status
8<----------------------------------------------------------------------

8<----------------------------------------------------------------------
$ gcc -o nf-queue nf-queue.c -g3 -gdwarf-4 -Wall -lmnl -lnetfilter_queue
$ 8<----------------------------------------------------------------------

8<----------------------------------------------------------------------
$ !84038
gcc -g3 -ggdb -Wall -lmnl -lnetfilter_queue -o nf-queue nf-queue.c
/usr/bin/ld: /tmp/ccPlG4la.o: in function `nfq_send_verdict':
/home/ged/nf-queue.c:30: undefined reference to `nfq_nlmsg_put'
/usr/bin/ld: /home/ged/nf-queue.c:31: undefined reference to `nfq_nlmsg_verdict_put'
/usr/bin/ld: /home/ged/nf-queue.c:34: undefined reference to `mnl_attr_nest_start'
/usr/bin/ld: /home/ged/nf-queue.c:37: undefined reference to `mnl_attr_put_u32'
/usr/bin/ld: /home/ged/nf-queue.c:41: undefined reference to `mnl_attr_nest_end'
/usr/bin/ld: /home/ged/nf-queue.c:43: undefined reference to `mnl_socket_sendto'
/usr/bin/ld: /tmp/ccPlG4la.o: in function `queue_cb':
/home/ged/nf-queue.c:60: undefined reference to `nfq_nlmsg_parse'
/usr/bin/ld: /home/ged/nf-queue.c:65: undefined reference to `mnl_nlmsg_get_payload'
/usr/bin/ld: /home/ged/nf-queue.c:75: undefined reference to `mnl_attr_get_payload'
/usr/bin/ld: /home/ged/nf-queue.c:78: undefined reference to `mnl_attr_get_payload_len'
/usr/bin/ld: /home/ged/nf-queue.c:93: undefined reference to `mnl_attr_get_u32'
/usr/bin/ld: /home/ged/nf-queue.c:97: undefined reference to `mnl_attr_get_u32'
/usr/bin/ld: /home/ged/nf-queue.c:111: undefined reference to `mnl_attr_get_payload'
/usr/bin/ld: /tmp/ccPlG4la.o: in function `main':
/home/ged/nf-queue.c:162: undefined reference to `mnl_socket_open'
/usr/bin/ld: /home/ged/nf-queue.c:168: undefined reference to `mnl_socket_bind'
/usr/bin/ld: /home/ged/nf-queue.c:172: undefined reference to `mnl_socket_get_portid'
/usr/bin/ld: /home/ged/nf-queue.c:184: undefined reference to `nfq_nlmsg_put'
/usr/bin/ld: /home/ged/nf-queue.c:185: undefined reference to `nfq_nlmsg_cfg_put_cmd'
/usr/bin/ld: /home/ged/nf-queue.c:187: undefined reference to `mnl_socket_sendto'
/usr/bin/ld: /home/ged/nf-queue.c:195: undefined reference to `nfq_nlmsg_put'
/usr/bin/ld: /home/ged/nf-queue.c:196: undefined reference to `nfq_nlmsg_cfg_put_params'
/usr/bin/ld: /home/ged/nf-queue.c:198: undefined reference to `mnl_attr_put_u32'
/usr/bin/ld: /home/ged/nf-queue.c:199: undefined reference to `mnl_attr_put_u32'
/usr/bin/ld: /home/ged/nf-queue.c:201: undefined reference to `mnl_socket_sendto'
/usr/bin/ld: /home/ged/nf-queue.c:211: undefined reference to `mnl_socket_setsockopt'
/usr/bin/ld: /home/ged/nf-queue.c:217: undefined reference to `mnl_socket_recvfrom'
/usr/bin/ld: /home/ged/nf-queue.c:223: undefined reference to `mnl_cb_run'
collect2: error: ld returned 1 exit status
$ 8<----------------------------------------------------------------------

This is where I'd got to when I sent the OP:

8<----------------------------------------------------------------------
$ !84039
gcc -o nf-queue nf-queue.c -g3 -ggdb -Wall -lmnl -lnetfilter_queue
$
8<----------------------------------------------------------------------

2. The first line output by the command "gcc --version"

$ gcc --version | head -n1
gcc (Debian 10.2.1-6) 10.2.1 20210110

This is a raspberry Pi4B, 8GBytes, 64 bit.

8<----------------------------------------------------------------------
$ uname -a
Linux raspberrypi 6.1.21-v8+ #1642 SMP PREEMPT Mon Apr  3 17:24:16 BST 2023 aarch64 GNU/Linux
$ 8<----------------------------------------------------------------------

There were other problems when I tried the same thing on x86, but that
was gcc version 8, so I think they can be ignored.

Thanks again.  Please note that this isn't a problem for me - it's
just me trying to get docs in order whenever I see something odd.

--

73,
Ged.




[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux