I am trying to compile libnetfilter_queue package in ubuntu20.04, having installed all necessary dependencies. I have to create a binary file in order to compile it in a IMX8 microprocessor with debian, but when i do the next compilation:
g++ -o xg.bin ./src/main.cpp ./src/packet.cpp -lnetfilter_queue -lssl -lcrypto
It throws the following errors:
/usr/bin/ld: /tmp/cc1h6Iqp.o: in function `on_packet(nfq_q_handle*, nfgenmsg*, nfq_data*, void*)':
main.cpp:(.text+0x6a): undefined reference to `nfq_get_msg_packet_hdr'
/usr/bin/ld: main.cpp:(.text+0x94): undefined reference to `nfq_get_nfmark'
/usr/bin/ld: main.cpp:(.text+0xad): undefined reference to `nfq_get_payload'
/usr/bin/ld: main.cpp:(.text+0xec): undefined reference to `pktb_alloc(int, void*, unsigned long, unsigned long)'
/usr/bin/ld: main.cpp:(.text+0x12d): undefined reference to `nfq_ip_get_hdr(pkt_buff*)'
/usr/bin/ld: main.cpp:(.text+0x181): undefined reference to `nfq_ip_set_transport_header(pkt_buff*, iphdr*)'
/usr/bin/ld: main.cpp:(.text+0x1da): undefined reference to `nfq_tcp_get_hdr(pkt_buff*)'
/usr/bin/ld: main.cpp:(.text+0x1fc): undefined reference to `nfq_tcp_get_payload(tcphdr*, pkt_buff*)'
/usr/bin/ld: main.cpp:(.text+0x213): undefined reference to `nfq_tcp_get_payload_len(tcphdr*, pkt_buff*)'
/usr/bin/ld: main.cpp:(.text+0x2c4): undefined reference to `nfq_tcp_compute_checksum_ipv4(tcphdr*, iphdr*)'
/usr/bin/ld: main.cpp:(.text+0x2d0): undefined reference to `pktb_data(pkt_buff*)'
/usr/bin/ld: main.cpp:(.text+0x2df): undefined reference to `pktb_len(pkt_buff*)'
/usr/bin/ld: main.cpp:(.text+0x2fd): undefined reference to `nfq_set_verdict'
/usr/bin/ld: main.cpp:(.text+0x321): undefined reference to `nfq_set_verdict'
/usr/bin/ld: main.cpp:(.text+0x353): undefined reference to `nfq_udp_get_hdr(pkt_buff*)'
/usr/bin/ld: main.cpp:(.text+0x375): undefined reference to `nfq_udp_get_payload(udphdr*, pkt_buff*)'
/usr/bin/ld: main.cpp:(.text+0x38c): undefined reference to `nfq_udp_get_payload_len(udphdr*, pkt_buff*)'
/usr/bin/ld: main.cpp:(.text+0x423): undefined reference to `nfq_udp_compute_checksum_ipv4(udphdr*, iphdr*)'
/usr/bin/ld: main.cpp:(.text+0x42f): undefined reference to `pktb_data(pkt_buff*)'
/usr/bin/ld: main.cpp:(.text+0x43e): undefined reference to `pktb_len(pkt_buff*)'
/usr/bin/ld: main.cpp:(.text+0x45c): undefined reference to `nfq_set_verdict'
/usr/bin/ld: main.cpp:(.text+0x480): undefined reference to `nfq_set_verdict'
/usr/bin/ld: main.cpp:(.text+0x4b5): undefined reference to `nfq_set_verdict'
Does anybody know what is happening? I also tried to link the libraries in a manual way via ldconfig, but I figure out that they are already linked. Any idea?
--- COMPILATION FILES --- tasks.json:
{
"version": "2.0.0",
/* Configure Debian SDK Constants from settings.json */
"options": {
"env": {
"CXX": "${config:VARISCITE.CXX}", /* Used by Makefile */
"CC": "${config:VARISCITE.CC}", /* Used by Makefile */
}
},
/* Configure integrated VS Code Terminal */
"presentation": {
"echo": false,
"reveal": "always",
"focus": true,
"panel": "dedicated",
"showReuseMessage": true,
},
"tasks": [
/* Configure Build Task */
{
"label": "sudo build",
"type": "shell",
"command": "make clean; make -j$(nproc)",
"problemMatcher": ["$gcc"]
},
]
}
settings.json:
{
"VARISCITE": {
/* Target Device Settings */
"TARGET_IP":"192.168.1.69",
/* Project Settings */
"PROGRAM":"xg.bin",
"PROGRAM_PATH":"build/xg.bin",
/* Debian SDK Configuration */
"ARCH":"aarch64-linux-gnu",
"TOOLCHAIN":"/home/raulgimenez/debian-imx8mm-var-dart/toolchain/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu",
"TARGETSYSROOT":"/home/raulgimenez/debian-imx8mm-var-dart/toolchain/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/aarch64-linux-gnu/libc/usr/include",
/* Debian SDK Constants */
"CC_PREFIX": "${config:VARISCITE.TOOLCHAIN}/bin/${config:VARISCITE.ARCH}-",
"CXX": "${config:VARISCITE.CC_PREFIX}g++ --sysroot=${config:VARISCITE.TARGETSYSROOT}",
"CC": "${config:VARISCITE.CC_PREFIX}gcc --sysroot=${config:VARISCITE.TARGETSYSROOT}",
},
"files.associations": {
"cstdlib": "cpp"
},
"C_Cpp.errorSquiggles": "enabled"
}
c_cpp_properties.json:
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"${config:VARISCITE.TARGETSYSROOT}/**",
"/usr/include/**"
]
}
],
"version": 4
}
Thanks in advance, R.
UPDATE: I Finally find the paths for using this library, but it fails. It is running on debian installed in a Variscite IMX8 microprocessor, does anybody know why could be failing?