Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System.DllNotFoundException: libpcap.so #33

Closed
sbrl opened this issue Jan 1, 2018 · 7 comments
Closed

System.DllNotFoundException: libpcap.so #33

sbrl opened this issue Jan 1, 2018 · 7 comments

Comments

@sbrl
Copy link

sbrl commented Jan 1, 2018

Hello,

I've hit upon an exception when trying to use this library:

Unhandled Exception:
System.DllNotFoundException: libpcap.so
  at (wrapper managed-to-native) SharpPcap.LibPcap.LibPcapSafeNativeMethods:pcap_findalldevs (intptr&,System.Text.StringBuilder)
  at SharpPcap.LibPcap.LibPcapLiveDeviceList.GetDevices () [0x00017] in <6f754ff0acd74248b20ed8bbfa5b7c57>:0 
  at SharpPcap.LibPcap.LibPcapLiveDeviceList.Refresh () [0x0000c] in <6f754ff0acd74248b20ed8bbfa5b7c57>:0 
  at SharpPcap.LibPcap.LibPcapLiveDeviceList..ctor () [0x0000b] in <6f754ff0acd74248b20ed8bbfa5b7c57>:0 
  at SharpPcap.LibPcap.LibPcapLiveDeviceList.get_Instance () [0x00007] in <6f754ff0acd74248b20ed8bbfa5b7c57>:0 
  at SharpPcap.CaptureDeviceList..ctor () [0x00032] in <6f754ff0acd74248b20ed8bbfa5b7c57>:0 
  at SharpPcap.CaptureDeviceList.get_Instance () [0x00007] in <6f754ff0acd74248b20ed8bbfa5b7c57>:0 
  at PacketCaptureMIDIDemo.PacketCapturer.LogDeviceList () [0x00002] in <426db04d9d0e45fe85d32d6e40196029>:0 
  at PacketCaptureMIDIDemo.MainClass.Main (System.String[] args) [0x00007] in <426db04d9d0e45fe85d32d6e40196029>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.DllNotFoundException: libpcap.so
  at (wrapper managed-to-native) SharpPcap.LibPcap.LibPcapSafeNativeMethods:pcap_findalldevs (intptr&,System.Text.StringBuilder)
  at SharpPcap.LibPcap.LibPcapLiveDeviceList.GetDevices () [0x00017] in <6f754ff0acd74248b20ed8bbfa5b7c57>:0 
  at SharpPcap.LibPcap.LibPcapLiveDeviceList.Refresh () [0x0000c] in <6f754ff0acd74248b20ed8bbfa5b7c57>:0 
  at SharpPcap.LibPcap.LibPcapLiveDeviceList..ctor () [0x0000b] in <6f754ff0acd74248b20ed8bbfa5b7c57>:0 
  at SharpPcap.LibPcap.LibPcapLiveDeviceList.get_Instance () [0x00007] in <6f754ff0acd74248b20ed8bbfa5b7c57>:0 
  at SharpPcap.CaptureDeviceList..ctor () [0x00032] in <6f754ff0acd74248b20ed8bbfa5b7c57>:0 
  at SharpPcap.CaptureDeviceList.get_Instance () [0x00007] in <6f754ff0acd74248b20ed8bbfa5b7c57>:0 
  at PacketCaptureMIDIDemo.PacketCapturer.LogDeviceList () [0x00002] in <426db04d9d0e45fe85d32d6e40196029>:0 
  at PacketCaptureMIDIDemo.MainClass.Main (System.String[] args) [0x00007] in <426db04d9d0e45fe85d32d6e40196029>:0 
@chmorgan
Copy link
Collaborator

chmorgan commented Jan 1, 2018 via email

@sbrl
Copy link
Author

sbrl commented Jan 2, 2018

Hey, thanks for the quick reply! Oops, it looks like I haven't included my system details - I meant to do that! Here they are:

I see (amongst other things) libpcap0.8 that's apparently automatically installed when I do an apt search libpcap. Here's a snippet of the output there:

libpcap-dev/zesty,zesty 1.8.1-3ubuntu1 all
  development library for libpcap (transitional package)

libpcap0.8/zesty,now 1.8.1-3ubuntu1 amd64 [installed,automatic]
  system interface for user-level packet capture

libpcap0.8-dbg/zesty 1.8.1-3ubuntu1 amd64
  debugging symbols for libpcap0.8

libpcap0.8-dev/zesty 1.8.1-3ubuntu1 amd64
  development library and header files for libpcap0.8

libwiretap-dev/zesty-updates,zesty-security 2.2.6+g32dac6a-2ubuntu0.17.04 amd64
  network packet capture library -- development files

libwiretap6/zesty-updates,zesty-security,now 2.2.6+g32dac6a-2ubuntu0.17.04 amd64 [installed,automatic]
  network packet capture library -- shared library

ncaptool/zesty 1.9.2-2.2 amd64
  network capture tool

I've also tested this library on Artix Linux (A variant of Arch that doesn't use systemd), and it works like charm - so I'm inclined to think that I'm missing a package - but I'm not sure which one I'm missing.

Thanks for the assistance!

@chmorgan
Copy link
Collaborator

chmorgan commented Jan 3, 2018 via email

@sbrl
Copy link
Author

sbrl commented Jan 3, 2018

Ah, thanks! Probing deeper my config file contained this:

<!-- Configuration file used by Mono to aid in dll mapping between platforms so the same
     assembly can be used on Windows, where it will find wpcap.dll, and on linux/mac where
     Mono will map the dll to libpcap.so.
     This file should be placed along side of the assembly dll or in a system searchable location.
     See http://www.mono-project.com/Interop_with_Native_Libraries#Library_Names -->
<configuration>
	<dllmap dll="wpcap" target="libpcap.so" />
</configuration>

...and while I had the following files:

/usr/lib/x86_64-linux-gnu/libpcap.so.0.8
/usr/lib/x86_64-linux-gnu/libpcap.so.1.8.1

....I didn't have a symlink called libpcap.so. To that end, creating it seems to have done the trick. Thanks for the assistance! 😺

@porscheme
Copy link

Platform: Docker Alpine Container and DotNet core
LibpCap installed

I am getting dll not error
stack trace
GetSystem.DllNotFoundException: Unable to load shared library 'libpcap' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: Error loading shared library liblibpcap: No such file or directory\n at SharpPcap.LibPcap.Unix.pcap_findalldevs(IntPtr& alldevs, StringBuilder errbuf)\n at SharpPcap.LibPcap.LibPcapLiveDeviceList.GetDevices()\n at SharpPcap.LibPcap.LibPcapLiveDeviceList.Refresh()\n at SharpPcap.LibPcap.LibPcapLiveDeviceList.get_Instance()\n at TestWebApp.PacketCapture.GetUniqueNetworkDevice(String devicePartialName) in /app/TestWebApp/LivePackets/PacketCapture.cs:line 96\n at TestWebApp.Controllers.ValuesController.Get() in /app/TestWebApp/Controllers/ValuesController.cs:line 26

@sbrl
Copy link
Author

sbrl commented Jun 17, 2019

Hey, @porscheme! Since this issue has been closed for a while, it might be worth opening a new issue with that information.

Also, you can use the triple-backtick syntax to make something appear in a code block on GitHub, which would make that stack trace easier to read. Like this:

```
Enter stack trace here
```

@porscheme
Copy link

porscheme commented Jun 17, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants