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

Doesn't work on Windows 10 #156

Closed
robert-dzikowski opened this issue Jul 12, 2023 · 6 comments
Closed

Doesn't work on Windows 10 #156

robert-dzikowski opened this issue Jul 12, 2023 · 6 comments
Labels

Comments

@robert-dzikowski
Copy link

I can't compile any program on Windows 10 that uses this library

λ go build
package github.com/go-gl/example/gl41core-cube
        imports github.com/go-gl/gl/v4.1-core/gl: build constraints exclude all Go files in C:\Users\Robert\go\pkg\mod\github.com\go-gl\gl@v0.0.0-20211210172815-726fda9656d6\v4.1-core\gl

λ go build
package github.com/icexin/gocraft
        imports github.com/go-gl/gl/v3.3-core/gl: build constraints exclude all Go files in C:\Users\Robert\go\pkg\mod\github.com\go-gl\gl@v0.0.0-20211210172815-726fda9656d6\v3.3-core\gl

@robert-dzikowski
Copy link
Author

That problem doesn't occur in github.com/go-gl/glfw/v3.3/glfw although it was present in version 3.2 of that library.

@dmitshur
Copy link
Member

What version of Go are you using? Is there a C compiler in %PATH%? What happens if you set CGO_ENABLED to 1 and try go build again?

@robert-dzikowski
Copy link
Author

I don't think I have C compiler, what C compiler I should use for Windows?
I use go1.20.5 windows/amd64
I set CGO_ENABLED=1 and nothing changed.

@dmitshur
Copy link
Member

I don't think I have C compiler, what C compiler I should use for Windows?

This package uses cgo, so a C compiler is required. See requirements at https://github.com/go-gl/gl#readme.

https://go.dev/wiki/cgo#windows lists mingw-w64 as one example of a C compiler that can be used on Windows. There may be more options available.

I set CGO_ENABLED=1 and nothing changed.

That's unexpected. It you set CGO_ENABLED to 1 and try to build this package (or something that imports it), and a C compiler is not available in PATH, it should fail with something like:

$ CGO_ENABLED=1 go build github.com/go-gl/gl/v3.3-core/gl
# runtime/cgo
cgo: C compiler "gcc" not found: exec: "gcc": executable file not found in %PATH%

@Folium1
Copy link

Folium1 commented Jul 14, 2023

On macOS I use mingw-w64 for building, here my building command:

b: @CGO_ENABLED=1 CC=/opt/homebrew/bin/x86_64-w64-mingw32-gcc GOOS=windows GOARCH=amd64 go build -tags=gl_v4_6_core -o install.exe

@robert-dzikowski
Copy link
Author

It works now. I used GCC from https://winlibs.com and set CGO_ENABLED=1.

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

No branches or pull requests

3 participants