-
-
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 compiling fails #384
Comments
Maybe you don't install/set cross C compiler for Linux. |
Is that |
Not host compiler. I mean cross compiler. Install cross C compiler, then set $CC. |
So I've installed this: https://github.com/crosstool-ng/crosstool-ng No luck. So I tried setting env $CC to ct-ng first, still no luck. Unsure where to go from here. Sorry to be a pest! 🙏 |
Unfortunately, I don't have OSX. So that's all I can tell you. Sorry |
Well, the good news is that I can build Linux just fine if I boot an Arch VM and do it from there. Still no idea how to get it working from within macOS, so if anyone wants to chime in that'd be appreciated. :-) |
Hi Mattn, I have the same problem with go 1.8. OS: Linux x86_64 |
Maybe your CGO_ENABLED is 0 |
With go 1.7 I can cross compile without a C cross compiler (like mingw). I can use the native go compiler and have no problems. # This works, but only with go 1.7
# Not with go 1.8
env CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build If I understood it right Is enabled cgo a new dependency if I want to use your package with go 1.8? Thanks for your work and your time! |
Maybe, the driver built on go1.7 does not work. It should be empty module. |
I'm now having the same problem when trying to compile specifically this for ARM. It was working fine with go 1.7 for me as well. |
Noticed this as well, trying to create some workaround.. I am a bit sceptical that this is related to Go 1.8 as I have been using it since December and it was compiling fine. Something else changed. |
Hmm....I tried backtracking and using go-sqlite3 at f043f80, which was at the beginning of November with the same problem. |
After checkout the revision b5c99a7 (2017-08-21) the compilation is working. |
Does it look like 98981b4 is the commit that breaks cross-compiling on go 1.8? |
@FiloSottile It seems related with your commit. Can you handle this issue? If it was temporary issue for some version of go, I'll revert the commit. Thanks. |
No, I don't think that 98981b4 is the breaking point. Firstly, the commit 5811704 to undo the changes. Secondly, the cross compilation does not work with both versions. If I checkout the revision b5c99a7 the cross compilation works. But the binary does not work. I'm not sure if this a problem of version mixing (go-sqlite supports only go 1.6 on this point but I use go 1.8) or a problem of the cross compilation. @mattn Should it be possible to cross compile go-sqlite without enabled CGO? |
go-sqlite3 is CGO module. So you need to enable CGO always. |
Huh, I'm surprised. It seemed to be compiling and running fine until go 1.8. I'm not why then. |
Then we can close the issue from my point of view. I have tried to cross compile without CGO. This can not work. |
I experienced the same problems as described by this thread, but I was eventually able to get things to work. From a linux amd64 host, I was finally able to cross compile for linux arm. Posting below, in case it may be useful for anyone.
|
@dcwangmit01 what package did you install to make arm-linux-gnueabihf-gcc-5 available on your system? |
@gabrielruiu install |
Can't find the correct compiler arguments for OSX to linux using the clang compiler, help greatly appreciated thx
|
No ended up using another linux docker container and compile it in that docker container instead. Sad that c compilers still make life hard even today for just a few parameters |
I have the same problem. I can see errors. |
What is bad? sqlite3 is written in C code. so You MUST use CGO. |
I succeeded to cross compile from macos to linux using musl-cross. using this command line:
Hope this helps others. |
@carosatig just what I was looking for! thanks for figuring that out for us. i'm not too familiar with the cgo compilation process, do you mind explaining why |
I am cross compiling using xgo. Here is my working solution https://github.com/dnote/cli/blob/fa1da50fc5f8f9ef9df23a35a86e497ed9a9bbff/scripts/build.sh#L31-L60 in case it helps anyone. |
THANKS! Really saved my day~ |
CC=mips-linux-musl-gcc CXX=mips-linux-musl-g++ CGO_ENABLED=1 GOOS=linux GOARCH=mipsle GOMIPS=softfloat go build -ldflags="-s -w" main.go How can i build for little endian?Thank you! |
You should probably open a new issue rather than commenting on one that’s already been closed. Please include the actual problem you’ve encountered. If it’s failing to compile, please include any error messages. |
ok , thank you! |
compiling for linux on macOS can refer this solution #797 |
@carosatig 's comment was quite helpful in resolving compilation issues on OSX. I'd recommend documenting this. @mattn Please let me know if you would be okay with me creating a PR that appends this information to |
Yes, please. |
* Document requirements for cross compiling from OSX Inspiration: #384 (comment) * Document cross compilation steps using xgo for MACOSX
Good |
Very possibly a mistake on my part, if so please let me know where I went wrong. My first time with Go today!
I have a basic Go file using this library. I am on macOS
10.12.3
, Go1.8 darwin/amd64
.Succeeds:
env GOOS=darwin go build -i app.go
Fails:
env GOOS=linux go build -i app.go
Specifying
GOARCH=amd64
makes no difference.Errors:
Said very basic Go file causing this, in-case it helps:
The text was updated successfully, but these errors were encountered: