Hello, I am trying to import C functions from pcap.h library, however without much success. For now I am just trying to print out a integer return from pcap_findalldevs() funcion. This is the code: type pcap_if {.importc: "struct pcap_if", header: "<pcap.h>"} = object next: ptr pcap_if name: cstring description: cstring flags: uint32 pcap_if_t {.importc: "struct pcap_if_t", header: "<pcap.h>"} = pcap_if proc pcap_findalldevs(a: ptr ptr pcap_if_t, b:cstring) : cint {.importc, header: "<pcap.h>"} var dev_list: ptr pcap_if_t echo pcap_findalldevs(addr(dev_list), nil) Run
Compiled with: nim c -r ipk.nim --passL:"-L/usr/include/ -lpcap" Run But this is the error message I get: @mipk.nim.c:(.text+0x278): undefined reference to `pcap_findalldevs' collect2: error: ld returned 1 exit status Error: execution of an external program failed: 'gcc -o /root/ipk2/ipk /root/.cache/nim/ipk_d/stdlib_io.nim.c.o /root/.cache/nim/ipk_d/stdlib_system.nim.c.o /root/.cache/nim/ipk_d/@mipk.nim.c.o -ldl' Run Could somebody help me please? It seems like it doesn't want to link properly, although I did also try linking with just --clib:pcap and --clib:pcap.h Run