kwtucker
(Kevin Tucker)
October 19, 2016, 9:59pm
1
Hello all,
I am trying to build my app on my mac for linux by running this command while in the my app directory that has a main:
env GOOS=linux GOARCH=arm GOARM=7 go build
The build process goes okay,
I did make it make sure it is executable by running this command:
chmod +x app
Once I get it to the linux server and run it I get:
-bash: ./app: cannot execute binary file: Exec format error
I have Go 1.7.0
Any one have any idea what I am doing wrong?
joeybloggs
(Dean Karn)
October 20, 2016, 12:52am
2
There are a couple more options needed to make it truly static and runnable:
env CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=7 go build -installsuffix cgo
kwtucker
(Kevin Tucker)
October 20, 2016, 3:15am
3
So this would work? I didn’t no if the last part cgo was required?
env CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=7 go build -v
UPDATE: sorry I was half asleep when posting, I missed the -a flag in the command.
here is a great article about dockerizing a go application, if you skip down to the compile section you will see the full command needed and a full explanation of what the flags are doing.
hope this can help
1 Like
calmh
(Jakob Borg)
October 20, 2016, 7:16am
5
Are you in fact deploying to an ARM box…?
1 Like
pieterlouw
(Pieter Louw)
October 20, 2016, 1:13pm
6
I agree with @calmh , make sure your target machine is in fact an ARM box.
Here’s a list of possible enironment variables to use: $GOOS and $GOARCH environent variables
calmh
(Jakob Borg)
October 20, 2016, 1:36pm
9
I have a:
Ubuntu 16.04.1 x64
So you want GOOS=linux GOARCH=amd64
.
2 Likes
kwtucker
(Kevin Tucker)
October 20, 2016, 1:37pm
10
Fixed the problem. My server was not an ARM:
This command worked just fine:
env GOOS=linux GOARCH=amd64 go build
Sorry everyone i am super new at deployment.
2 Likes
system
(system)
Closed
January 18, 2017, 1:37pm
11
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.