dtpwra8456 2018-03-04 20:30
浏览 3143
已采纳

尝试在Windows 10上为Linux构建Go代码时出错

I try to build Go code on Windows with CGO_ENABLED=1. I have a .bat file with

set GOOS=linux
set GOARCH=amd64
set CGO_CFLAGS=-g -O2 -w
set CGO_ENABLED=1
go build main.go constants.go functions.go

But I get error:

gcc_linux_amd64.c: In function '_cgo_sys_thread_start':
gcc_linux_amd64.c:62:2: error: unknown type name 'sigset_t'
  sigset_t ign, oset;
  ^

What should I do? I could't find such error anywhere.

P.S. If I haven't got "-w" flag in "CGO_CFLAGS" I will get this:

# runtime/cgo
_cgo_export.c:1:0: error: -fPIC ignored for target (all code is position 
independent) [-Werror]
 /* Created by cgo - DO NOT EDIT. */
 ^
cc1.exe: all warnings being treated as errors
  • 写回答

1条回答 默认 最新

  • du0204 2018-03-15 10:51
    关注

    It seems that you need a cross compiler and the dev environment for compiling a C program for Linux. After searching around, this post may help: https://stackoverflow.com/a/4770417/3196456 .

    Or, as you are using Windows 10, a more easier way is to try Windows Subsystem for Linux, which can give you a whole Linux development experience on Windows. If your Windows build is greater than 16215, you can directly install one through Microsoft Store, for example, Ubuntu.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程
  • ¥20 模型在y分布之外的数据上预测能力不好如何解决