techknowlogick / xgo

Go CGO cross compiler
MIT License
467 stars 80 forks source link

I need to install libpcap-dev in the Images.how to operate. #210

Closed qq790382720 closed 1 year ago

qq790382720 commented 1 year ago

Build Command : xgo --targets=linux/arm .

Error: hecking for required docker image techknowlogick/xgo:latest... found. Cross compiling local repository: . : ... Enabled Go module support Building /source/go.mod... Compiling for linux/arm-5... /# github.com/google/gopacket/pcap /go/pkg/mod/github.com/google/gopacket@v1.1.19/pcap/pcap_unix.go:34:18: fatal error: pcap.h: No such file or directory

include

              ^

compilation terminated. Cleaning up build environment... Will,What am I supposed to do now

techknowlogick commented 1 year ago

You may need to use https://github.com/gopacket/gopacket instead as it looks to be a more up to date version of the gopacket library. In terms of adding the pcap c code, you could use the --deps argument. Something like --deps=https://gmplib.org/download/gmp/gmp-6.1.0.tar.bz2, but with the pcap code instead.

bearsh commented 1 year ago

another possibility is using hooks (-hooksdir), see also https://github.com/techknowlogick/xgo#hooks then you can install arbitrary pkg in you container (apt install -y libpcap-dev)

qq790382720 commented 1 year ago

another possibility is using hooks (-hooksdir), see also https://github.com/techknowlogick/xgo#hooks then you can install arbitrary pkg in you container (apt install -y libpcap-dev)

Can you give me an example? Thank you

bearsh commented 1 year ago

create a directory, e.g. .xgohooks in your project's directory. place a file with the name setup.sh with following content in it:

apt update && apt install -y libpcap-dev

the call xgo with the following option: xgo -hooksdir .xgohooks ...

bearsh commented 1 year ago

@qq790382720 did this work for you? can the issue be closed?

techknowlogick commented 1 year ago

I'll close this now, but please let me know if you need it re-opened :)