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

Where to place pcap.h file on Windows? #575

Closed
vaastav opened this issue Dec 18, 2018 · 5 comments
Closed

Where to place pcap.h file on Windows? #575

vaastav opened this issue Dec 18, 2018 · 5 comments

Comments

@vaastav
Copy link

vaastav commented Dec 18, 2018

Hi,
I am trying to use gopacket on windows but I get the following error:

github.com/google/gopacket/pcap

C:\Go-Path\src\github.com\google\gopacket\pcap\pcap.go:22:18: fatal error: pcap.h: No such file or directory
#include <pcap.h>
^
compilation terminated.

I know the issue is that I don't have libpcap installed. I found winpcap as an alternative which can provide the relevant header and source files. I was just confused as to where to place these files in relation to gopacket so that I have a successful compilation?

Thanks!!

@notti
Copy link
Collaborator

notti commented Dec 18, 2018

At the moment you have two possibilities:

  1. Try out pull request Move non-windows stuff to pcap_unix; Convert windows to implicit linking #568 with which you don't need any headers (therefore no winpcap sdk).
  2. Or put the winpcap sdk into C:/WpdPack/ as was used in:

    gopacket/pcap/pcap.go

    Lines 18 to 20 in 3c037fb

    #cgo windows CFLAGS: -I C:/WpdPack/Include
    #cgo windows,386 LDFLAGS: -L C:/WpdPack/Lib -lwpcap
    #cgo windows,amd64 LDFLAGS: -L C:/WpdPack/Lib/x64 -lwpcap

If you try 1. please report success or failure to the pull request. Thanks.

@vaastav
Copy link
Author

vaastav commented Dec 18, 2018

Hmm, if I use option 2 then I am still getting the following error :
exit status 3221225781

Seems like I am missing a dll....
Although there is wpcap.lib exists in the path specified in LDFLAGS

I haven't tried option 1 yet but I will let you know how it turns out for me if and when I try it.

@notti
Copy link
Collaborator

notti commented Dec 18, 2018

Oh sorry forgot; For 64 bit Windows you need to follow https://stackoverflow.com/questions/38047858/compile-gopacket-on-windows-64bit

@notti
Copy link
Collaborator

notti commented Jan 4, 2019

#568 got merged. Does it work for you?

@notti
Copy link
Collaborator

notti commented Feb 1, 2019

Closed due to inactivity and being out of date (cgo is not needed any longer on windows)

@notti notti closed this as completed Feb 1, 2019
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

2 participants