Skip to content
This repository has been archived by the owner on Nov 5, 2022. It is now read-only.

"no buildable Go source files in... " from cross compile #96

Closed
mxseev opened this issue Apr 6, 2015 · 4 comments
Closed

"no buildable Go source files in... " from cross compile #96

mxseev opened this issue Apr 6, 2015 · 4 comments

Comments

@mxseev
Copy link

mxseev commented Apr 6, 2015

I try compile windows app in linux, and get this error:
[ralvke@localhost client]$ GOOS=windows GOARCH=amd64 go build -o windows.exe ../../github.com/google/gxui/drivers/gl/blitter.go:11:2: no buildable Go source files in /home/ralvke/Documents/Go/src/github.com/go-gl/gl/v2.1/gl ../../github.com/google/gxui/drivers/gl/driver.go:14:2: no buildable Go source files in /home/ralvke/Documents/Go/src/github.com/go-gl/glfw/v3.1/glfw

@dmitshur
Copy link
Member

dmitshur commented Apr 6, 2015

You might need to set CGO_ENABLED=1 (possibly during your Go installation too), since both those packages use cgo.

The docs on cgo state:

To enable cgo during cross compiling builds, set the CGO_ENABLED environment variable to 1 when building the Go tools with make.bash. Also, set CC_FOR_TARGET to the C cross compiler for the target. CC will be used for compiling for the host.

I'm not sure if cross compilation is supported for those packages, but this would be the first step to try.

@zhangpy
Copy link

zhangpy commented Apr 7, 2015

I have same issue on ubuntu 14.04.
When I set CGO_ENABLED=1, I got

# runtime/cgo
gcc: error: unrecognized command line option ‘-mthreads’

I didn't find good solution, so I decided to install in windows.
I install mingw-w64 on windows and compile gxui successfully. FYI.

@ben-clayton
Copy link
Contributor

I'm afraid there's little I can do to help with this issue, as the problem seems to be with cross-compilation and/or go-gl. I'd recommend raising a bug there if your problem persists.

@EX0l0N
Copy link

EX0l0N commented Mar 2, 2017

When you use CGO_ENABLED=1 you also have to set CC and CXX to windows C(++) cross compilers. If you don't you'll be building and linking with your default host compilers.
You'll need some C(++) cross compiler suite to be installed.

I don't know if CXX_FOR_TARGET exists, or if it's being used, but setting it won't hurt.

# runtime/cgo
gcc: error: unrecognized command line option ‘-mthreads’

Is a typical exception you get for using the hosts gcc. -mthreads is a windows only gcc option.

I'm using
CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ CGO_ENABLED=1 GOOS=windows GOARCH=amd64 go build -v

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants