profile
viewpoint

Ask questionsWindows build

Hello,

I am trying to cross-compile for Windows, from Linux (with go1.12 linux/amd64, gcc version 7.4).

I have added the following to app/victoria-metrics/makefile:

victoria-metrics-amd64:
	CGO_ENABLED=1 GOARCH=amd64 GO111MODULE=on go build -mod=vendor -ldflags "$(GO_BUILDINFO)" -o bin/victoria-metrics-amd64.exe ./app/victoria-metrics

I then ran GOOS=windows GOARCH=amd64 make victoria-metrics-amd64 with this result:

# runtime/cgo
gcc: error: unrecognized command line option ‘-mthreads’; did you mean ‘-pthread’?
# github.com/VictoriaMetrics/VictoriaMetrics/lib/memory
lib/memory/memory.go:31:10: undefined: sysTotalMemory
app/victoria-metrics/Makefile:30: recipe for target 'victoria-metrics-amd64' failed
make: *** [victoria-metrics-amd64] Error 2

I do not have enough experience to proceed. Maybe you can help? Also, knowing the archictecture, is it feasible to run vm single node on Windows?

Thank you.

VictoriaMetrics/VictoriaMetrics

Answer questions cristihcd

I tried with to build on Ubuntu 18.04 / go v1.14 with: CGO_ENABLED=1: gcc: error: unrecognized command line option ‘-mthreads’; did you mean ‘-pthread’?

With CGO_ENABLED=0:

lib/fs/fs.go:291:12: undefined: unix.Flock
lib/fs/fs.go:291:41: undefined: unix.LOCK_EX
lib/fs/fs.go:291:54: undefined: unix.LOCK_NB
lib/fs/fs.go:306:11: undefined: unix.Statfs_t
lib/fs/fs.go:307:12: undefined: unix.Fstatfs
lib/fs/reader_at.go:60:13: undefined: unix.Munmap
lib/fs/reader_at.go:74:12: undefined: fadviseSequentialRead
lib/fs/reader_at.go:123:15: undefined: unix.Mmap
lib/fs/reader_at.go:123:52: undefined: unix.PROT_READ
lib/fs/reader_at.go:123:68: undefined: unix.MAP_SHARED
lib/fs/reader_at.go:123:68: too many errors

Full build command: CGO_ENABLED=0 GOOS=windows GOARCH=amd64 GO111MODULE=on go build -mod=vendor -o bin/victoria-metrics-amd64.exe ./app/victoria-metrics

The same for vmagent.

Thanks for looking into this.

useful!
source:https://uonfu.com/
Github User Rank List