-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Cross platform build failed #106
Comments
try to set CC=clang or CC=gcc On 1/29/14, elgs notifications@github.com wrote:
|
Seems to be the same:
|
The same happens for me. I am using an amd64 linux and trying to compile for windows, os x and freebsd. All of them fail with the same message.
I've tried |
Could you please try |
Still no luck.
|
It must be
Also, I've found this https://code.google.com/p/go/issues/detail?id=4714 . Seems like it is on the subject. CGO_ENABLED is forcefully set to 0 when corss compiling for some reason. |
Thanks @ironsmile, this time I got some more error messages:
|
Now I'm wondering if it is not possible to do cross platform compile as it contains c program, so it is not in pure go? |
Well It seems it is exactly that. For example when building for my native machine with
On the other hand when I try to cross compile with
You can find it in the go build tool source:
I am thinking of removing this and rebuilding my go tools :D But that will be left for later. |
@ironsmile WOW, what a hack you are going to do! |
@elgs Are you compiling windows executable!? |
Yeah I'm also having the same issue... nothing seems to be working. I tried this |
Having the same issue with cross-building on osx for linux amd64 |
I'm having a similar issues trying to cross-compile a windows executable from a 32-bit debian machine:
Looks to me like it's searching for a hardcoded mingw header file. |
@mattn, sorry for a late reply. Yes. I'm compiling windows executable. Finally I was able to compile both win32 and win64 executables from mingw32, but with mingw64, I can only compile win64 executable. |
@elgs What error message did you get on mingw64? |
As reported here |
Relevant Go issue: https://code.google.com/p/go/issues/detail?id=4714 |
CL57100043 was merged. Still have problem? |
Retrying with HEAD |
@mattn I'm sorry I have wiped out my mingw64 environment as building that windows executable was a one off thing last time. I will try to reproduce the same problem again and come back here with my update. |
NP :) |
Hello! I have the same problem that @jordan-wright had, have you been able to fix it? I am trying to build my project here: http://gobuild.io/build/github.com/agonzalezro/polo (darwin/amd64) but I get this output:
I will be happy to provide any more information than you need or do any other test, but "sadly", I am going to be disconnected for few days (sorry in advance). Thanks! |
Adding to this, I see the same when trying to compile for 32 bits on 64 bit Linux (not trying to cross compile to another OS, although that would be nice too); jb@udev2:~ $ go get github.com/mattn/go-sqlite3
jb@udev2:~ $ GOARCH=386 go get github.com/mattn/go-sqlite3
# github.com/mattn/go-sqlite3
src/github.com/mattn/go-sqlite3/sqlite3.c:92 unknown #: if
src/github.com/mattn/go-sqlite3/sqlite3.c:94 8c: No such file or directory: mingw.h
jb@udev2:~ $ go env
GOARCH="amd64"
GOBIN=""
GOCHAR="6"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/jb"
GORACE=""
GOROOT="/home/jb/go"
GOTOOLDIR="/home/jb/go/pkg/tool/linux_amd64"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"
jb@udev2:~ $ |
As the fix under https://code.google.com/p/go/issues/detail?id=4714 should be now in the 1.3 release, is there any chance to get cross compilation working? With Go 1.3 I'm getting ATM:
I'm on OS X and trying to build for ARM
|
@mattn |
@mattn github.com/mattn/go-sqlite3d:\go\go\src\pkg\github.com\mattn\go-sqlite3\sqlite3.c:92 unknown #: if |
Use goxc. And cross-compilable C compiler. |
Count you try this?
Your arm-c compiler seems having |
I'm running OS X 10.10. Is there a way to tell gcc to not define
I don't understand, why
vs.
Thanks |
Hey guys! I have same problem with gcc and gocx. I don't have impressive experience with compiled languages and i hope that you can tell me what wrongs. I've setup this package by "go get" and just include it to my source. When i try compile it by "goxc" i get "../github.com/mattn/go-sqlite3/sqlite3.c:94 8c: No such file or directory: mingw.h". @mattn you mentioned cross compiler, what is it? How i can install it and using? Why i've get this error message for all platforms exclude my host platform? Thank you. |
And if i run "GOOS=linux GOARCH=amd64 go build" complier works properly. I've got binary file. |
Okay, after 10 hours of researches i can do it with this link: http://www.limitlessfx.com/cross-compile-golang-app-for-windows-from-linux.html |
@marcboeker I was struggling with cross-compiling for raspberry pi as well. I ended up biting the bullet and installing Go on the RPi using http://dave.cheney.net/unofficial-arm-tarballs and compiling natively. Make sure you set VRAM to around 16 so compilation doesn't take forever! |
@imheresamir Thanks for the hint. Yeah, that's exactly what I'm doing at the moment and it is so slow :) But I'm going to try the VRAM option, hopefully this speeds things up. Thanks! |
@Smile42RU Thanks great post about cross compiling. Thanks all! |
Did anyone ever get this to cross-compile to Linux from a Mac OS X? |
Nope, unfortunately not :( |
@marcboeker I've had good luck using karalabe/xgo to cross-compile go-sqlite3 for ARM devices. Uses a docker linux container, but should be a lot faster than an RPi. |
@hasty Awesome, thanks for the tip! |
Hi, this is how I cross compile binary for freescale/arm on i386 architecture:
|
Thanks! |
I have the same problem on osx, attempting to build linux/amd64 version for my program.
|
try with |
@mattn Hello,
|
are you doing cross-compiling? when you need to use cross-compiler not host-compiler. |
@mattn Thanks. |
Ran into similar issue cross-compiling a linux binary on osx. Near as I can tell in my mini investigation, cross-compiling would work except that osx's implementation of the linker tool ( I have a simple work around using docker which will hopefully help others who don't want to go through the trouble of recompiling a linux version of Note: Naturally a docker workaround will require that you have docker installed :) @mattn If you think it's reasonable feel free to add it to your readme where it will be more visible. I can make a PR as well if you like.
This will put your executable in the expected place, in this case, You just need to update that If you want this working in a script like I have (for example I use a python fabric script to build and deploy automatically), you can do the following to prep docker on osx, since otherwise it requires the "Docker Quickstart Terminal":
In theory this should work on any platform that can run docker, though I've only tried on osx. |
@jeffbmartinez Thanks. Using docker is one of the way to do cross-compiling. So it's useful. If possible, could you please send me pull-request to update README.md? |
Leaving this comment in the hopes it helps someone else in 2016. Cross compiling Linux (Debian Jessie amd64) -> Windows (amd64) and OSX (amd64) worked for me with the following: To Windows: To OSX: |
@cprevallet Thank you, (ubuntu)work for windows.
|
for documentation purposes: |
@jeffbmartinez use docker run --rm with sqlite3 , i cannot build , sth is wrong , go build -v is nothing with hold.. |
Thanks @jeffbmartinez, it got me on the right track to get cross compilation working for Raspberry Pi 3. In case it's useful for anyone else, here's the Dockerfile I'm using for OSX:
And the command to build a package from the package directory: PWD=$(pwd)
PROJECT="/go${PWD/"$GOPATH"/}"
docker run --rm -v $GOPATH:/go -w $PROJECT \
-e "CGO_ENABLED=1" -e "GOARCH=arm" \
go-arm-linux:latest go build . |
After some searching, I found a way to cross compilation on OSX:
Ex:
Reference: https://blog.filippo.io/easy-windows-and-linux-cross-compilers-for-macos/ |
When I tried to build from OS X for Linux, it says:
The text was updated successfully, but these errors were encountered: