1

I am trying to use npcap SDK in VScode on Windows 10 computer.

I've written the correct path to Include directory and Lib directory of the SDK in file c_cpp_properties.json and proper command in file tasks.json.

But when I ran my test.c file, it didn't compile successfully.


Here is the output of the console:

Executing task: D:\Software\MinGW\mingw-w64\mingw64\bin\gcc.exe -g d:\workspace\c\npcapTest\test.c -I D:\Software\wireshark\npcap_sdk\npcap-sdk-1.05\Include -L D:\Software\wireshark\npcap_sdk\npcap-sdk-1.05\Lib\X64 -o d:\workspace\c\npcapTest\test.exe <


C:\Users\Aoki\AppData\Local\Temp\cch72D04.o: In function `main':

d:/workspace/c/npcapTest/test.c:16: undefined reference to `pcap_findalldevs_ex'

d:/workspace/c/npcapTest/test.c:38: undefined reference to `pcap_freealldevs'
collect2.exe: error: ld returned 1 exit status

It seems that something went wrong when linking to the .dll file. I've tried many methods, but I still don 't know how to solve this problem.

I'm new here, I can't upload pictures...

Matt Davis
  • 45,297
  • 16
  • 93
  • 124
pimentaw
  • 11
  • 1
  • Hi @pimentaw, welcome to stack overflow! Based on the error log, it looks like the error exists in your `test.c` file. It would probably help if you included that file (assuming it is your file, rather than a core file). – domdambrogia Jun 03 '20 at 22:05
  • Hi @domdambrogia!I just copied the code from the official website[link](https://nmap.org/npcap/guide/npcap-tutorial.html) and named the file test.c.The problem is that my gcc doesn't recognize these two functions('pcap_findalldevs_ex' and 'pcap_freealldevs') correctly – pimentaw Jun 04 '20 at 08:08
  • However,when pressing Ctrl key and hovering my mouse over the word 'pcap.h',VS code can correctly locate the `pcap.h` file.And if I click it,VS code can open it and display it in a window.All these show that VS code knows where the npcap SDK is,but the `test.c` file just can't be compiled successfully:( – pimentaw Jun 04 '20 at 08:22

0 Answers0