Skip to content

Conversation

@diredocks
Copy link
Contributor

When cross compiling on amd64-linux by CGO_ENABLED=1 GOOS=linux GOARCH=mips CC=mips-linux-gnu-gcc CGO_LDFLAGS="-L/tmp/libpcap-$PCAPV" go build, this error would occur:

# github.com/gopacket/gopacket/pcap
../../../go/pkg/mod/github.com/gopacket/[email protected]/pcap/pcap_unix.go:355:18: cannot use _Ctype_gopacket_time_secs_t(ci.Timestamp.Unix()) (value of type _Ctype_gopacket_time_secs_t) as _Ctype___time64_t value in assignment
../../../go/pkg/mod/github.com/gopacket/[email protected]/pcap/pcap_unix.go:356:19: cannot use _Ctype_gopacket_time_usecs_t(ci.Timestamp.Nanosecond() / 1000) (value of type _Ctype_gopacket_time_usecs_t) as _Ctype___suseconds64_t value in assignment

After some investigation, the reason is that the C macro at the beginning of pcap/pcap_unix.go failed to define gopacket_time_secs_t and gopacket_time_usecs_t properly.

This commit fix it and it works well when cross compiling with per-compiled libpcap.

@mosajjal mosajjal self-assigned this Sep 13, 2024
@mosajjal mosajjal merged commit 61dc5e7 into gopacket:master Oct 4, 2024
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

Successfully merging this pull request may close these issues.

2 participants