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?
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
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
Are you in fact deploying to an ARM box…?
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
I have a:
Ubuntu 16.04.1 x64
So you want
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.
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.