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

gcc: error: unrecognized command-line option ‘-mthreads’; did you mean ‘-pthread’? #238

Closed
muhdsalm opened this issue Jan 24, 2023 · 1 comment

Comments

@muhdsalm
Copy link

muhdsalm commented Jan 24, 2023

First off, I am compiling for windows on linux. I do have the windows compiler installed though.
This is the command I am running:
env GOOS=windows GOARCH=amd64 CGO_ENABLED=1 go build main.go
And this is the output:
# runtime/cgo
gcc: error: unrecognized command-line option ‘-mthreads’; did you mean ‘-pthread’?
How do I fix this?

@gen2brain
Copy link
Owner

You cannot use your host GCC compiler to compile for Windows, of course, that will not work. You need to install the appropriate toolchain with a compiler for the platform you want to compile for. In your case you need https://www.mingw-w64.org/ and something like CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc GOOS=windows GOARCH=amd64 go build. You can search the issues here, or search globally how to cross-compile CGO, i.e. you can for example use zig etc.

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

No branches or pull requests

2 participants