-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
make build command failed to compile gopacket package #3074
Comments
@shiqinfeng1 It seems that the command |
@gqcn This is output info, but it looks no problem?
|
复现代码安装依赖 yum install libpcap-devel 目录结构
配置 gfcli:
build:
name: 'goPktToolv2'
arch: 'amd64'
system: 'linux'
mod: 'none'
# packSrc: 'resource,manifest'
version: 'v2.0.0'
extra: ''
# cgo: true
源码 package main
import (
"fmt"
"log"
"github.com/google/gopacket/pcap"
)
func main() {
// 得到所有的(网络)设备
devices, err := pcap.FindAllDevs()
if err != nil {
log.Fatal(err)
}
// 打印设备信息
fmt.Println("Devices found:")
for _, device := range devices {
fmt.Println("\nName: ", device.Name)
fmt.Println("Description: ", device.Description)
fmt.Println("Devices addresses: ", device.Description)
for _, address := range device.Addresses {
fmt.Println("- IP address: ", address.IP)
fmt.Println("- Subnet mask: ", address.Netmask)
}
}
} |
在Windows下交叉编译也会出现同样的问题,用go build不会。 |
The same problem will occur when cross-compiling under Windows, but not when using go build. |
gcc加交叉编译比较麻烦。需要配合CC、CXX 、CGO_LDFLAGS 有空再研究 |
It is more troublesome to add cross compilation with gcc. Need to cooperate with CC, CXX, CGO_LDFLAGS and study again when you have time |
@shiqinfeng1 |
放弃了,在windows下开启cgo的情况,没法玩。 |
I gave up and couldn't play it when cgo was turned on under windows. |
命令gf build --debug -cgo=1在linux环境下,编译windows和linux版本都可以编译通过。不加-cgo=1的情况下,在linux下可以 编译成功win版本, 编译linux版本报错。 |
gf的版本:
现象:
代码中引用了gopacket包,使用makebuild命令编译,会编译失败:
cconfig.yaml配置为:
如果直接使用命令执行编译:go build -o ./temp/v2.0.0/linux_amd64/goPktToolv2 main.go ,就可以编译成功。
补充:
编译失败的文件中带有:
// +build !windows
The text was updated successfully, but these errors were encountered: