V
V
Vladimir2015-08-28 11:36:19
go
Vladimir, 2015-08-28 11:36:19

What is the problem with cross compiling in golang?

Hello, I can't figure out why cross compilation in golang doesn't work.
For example (a working machine with Linux mint, go version 1.5 ): GOOS=linux GOARCH=amd64 go build file.go
I get a file binary that runs successfully on a working machine either with a full path or ./file
But when I transfer it to a debian server (there I don't have go installed) and I chmod +x (with the full path or from the current folder) and try to do as above, writes: -bash: *waytofile*: No such file or directory
I try to set values ​​for both 32 bits and 64 - same.
In the same way, I tried to compile under win, file.exe was created, but on Windows it did not start, if you run it from the command line, a message was written something like: this is a 16-bit file and cannot start ...
What is the problem and how to compile normally at least for a server?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kirill, 2015-08-28
@FonVald

ldd to a file, there are some dependencies
either to build go build --ldflags '-extldflags "-static" -s' , or with CGO_ENABLED=0
PS: mint is a bit "fresh" than debian, so the binary is likely there are dependencies for libs that are not in Debian

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question