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

cmd/go: unhelpful error when cross-compiling for windows with cgo #20199

Open
josharian opened this Issue May 1, 2017 · 2 comments

Comments

Projects
None yet
3 participants
@josharian
Contributor

josharian commented May 1, 2017

package main

import "fmt"
import "C"

func main() {
	fmt.Printf("main=%p\n", main)
}
$ go build .
$ GOOS=windows go build .
can't load package: package .: no buildable Go source files in /Users/josh/go/tip/w

If you remove the import "C":

$ go build .
$ GOOS=windows go build .

If (like me) you didn't notice the import "C", this is a pretty puzzling error message.

@odeke-em

This comment has been minimized.

Member

odeke-em commented May 10, 2017

Am using OSX(darwin): same error when building for linux

$ GOOS=linux go build .
can't load package: package .: no buildable Go source files in /Users/emmanuelodeke/Desktop/openSrc/bugs/golang/20199

but when building for the same OS as the host OS, no error

$ GOOS=darwin go build . && echo successful
successful
@odeke-em

This comment has been minimized.

Member

odeke-em commented May 10, 2017

Update: one can reproduce the problem on the host OS == final OS if I set CGO_ENABLED=0 which might not make much sense since using import "C" but here is the error

$ GOOS=darwin CGO_ENABLED=0 go build . && echo successful
can't load package: package .: no buildable Go source files in /Users/emmanuelodeke/Desktop/openSrc/bugs/golang/20199

on Go version

$ go version
go version devel +643be70 Wed May 10 19:30:42 2017 +0000 darwin/amd64

@andybons andybons added this to the Unplanned milestone Apr 11, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment