Skip to content
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

Closed
josharian opened this Issue May 1, 2017 · 4 comments

Comments

Projects
None yet
5 participants
@josharian
Copy link
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.

Copy link
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.

Copy link
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

@bcmills

This comment has been minimized.

Copy link
Member

bcmills commented Jan 18, 2019

Dup of #24068?

@gopherbot

This comment has been minimized.

Copy link

gopherbot commented Feb 18, 2019

Timed out in state WaitingForInfo. Closing.

(I am just a bot, though. Please speak up if this is a mistake or you have the requested information.)

@gopherbot gopherbot closed this Feb 18, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.