N
N
Nikita Shoshin2018-03-05 21:46:26
linux
Nikita Shoshin, 2018-03-05 21:46:26

How to compile Go code on Windows under Linux?

I am trying to build a project on Windows 10 under Linux with CGO_ENABLED=1I have a .bat file with the following content:

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 after running it I get an 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?
PS If I don't have the "-w" flag in CGO_CFLAGS, then I 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

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
chromimon, 2018-03-10
@chromimon

CGO_ENABLED=1

Even directly on Windows, this would not be easy.
You need a C compiler that supports the target platform.
Faced with a similar problem, I once again thought - but did I pull something superfluous inside my program, which requires, in addition to the Go compiler, also the C compiler.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question