-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
Unable to build application for linux on windows machine #40129
Comments
Is your C compiler targeting Linux? You need a C cross compiler that targets Linux, and set CC environment variable to its path. |
If you look at my go env, cc is set to gcc and I am using following gcc verison: |
That C compiler targets mingw, not GNU/Linux. In order to build a GNU/Linux program on WIndows, with Closing because while the situation is unfortunate, there isn't really anything we can do in the Go toolchain to fix this. To build C code that runs on GNU/Linux you must have a C compiler that produces GNU/Linux code. |
Is there any way I can make C compiler targets to GNU on windows? |
Sure, but we are the wrong people to ask about that. A web search for "cross compile from windows to linux" pulls up a number of promising pages. |
I do not know. Maybe try Perhaps, @zv-io, can help.
I am not sure we should be the wrong people. If we support Mingw on Windows, we should provide link to download the tools. gcc is never installed on Windows, and Windows users rarely know what it is and how to install it. See, for example, #35006 (comment) Alex |
@alexbrainman I think the use of the word "GNU" was confusing here. This issue here isn't getting a GNU compiler that runs on Windows and generates programs that run on Windows. It's about getting a compiler that runs on Windows and generates programs that run on GNU/Linux. |
I understand what you meant, Ian. I suspect there is a version of gcc that runs on Windows and generates Linux binaries. It might be listed on http://musl.cc/ Alex |
Ah, OK, sorry. |
@ianlancetaylor @alexbrainman The toolchains at https://musl.cc/ are capable of at least:
If others are needed, just let me know. |
I need it for windows 10 machine to ubuntu 18(i.e. windows to linux). Should i pick this one x86_64-linux-musl-cross.zip ? |
Yes, that is correct.
Anything that is a I do not know if this will work for your intended purpose (it may require fiddling with environment variables and build flags, for example using |
Thanks for your help, @zv-io. @ianlancetaylor can we refer users to this website for pre-built Mingw binaries? I think this will be helpful to Windows cgo users. Alex |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
On windows mingw-w64 is installed for gcc and CGO_ENABLED is set to 1 which is needed for confluent-kafka-go library.
I am trying to build the application(which internally uses this library) for ubuntu on windows machine but compilation is failing.
compilation command: go build -o packet-handler myapp/main.go
What did you expect to see?
Application compiling successfully
What did you see instead?
$ go build -o packet-handler myapp/main.go
runtime/cgo
gcc_linux_amd64.c: In function '_cgo_sys_thread_start':
gcc_linux_amd64.c:61:2: error: unknown type name 'sigset_t'; did you mean '_sigset_t'?
sigset_t ign, oset;
^~~~~~~~
_sigset_t
gcc_linux_amd64.c:66:2: error: implicit declaration of function 'sigfillset' [-Werror=implicit-function-declaration]
sigfillset(&ign);
^~~~~~~~~~
gcc_linux_amd64.c:61:16: error: unused variable 'oset' [-Werror=unused-variable]
sigset_t ign, oset;
^~~~
cc1.exe: all warnings being treated as errors
The text was updated successfully, but these errors were encountered: