Open jay11ca39 opened 6 years ago
You need CGO enabled. Run this:
GOOS=linux GOARCH=arm go env
If is says CGO_ENABLED="0"
, you can't build zmq4 for this arch.
You may try to build zmq4 on ARM itself.
Yes, I am getting: CGO_ENABLED="0"
There is no way to do cross-compiling for zmq4 for arm arch ?
I tried enabling CGO but got different errors:
$ GOOS=linux GOARCH=arm go install ...
# .../vendor/github.com/pebbe/zmq4
src/.../vendor/github.com/pebbe/zmq4/reactor.go:10:4: undefined: State
src/.../vendor/github.com/pebbe/zmq4/reactor.go:11:9: undefined: State
$ GOOS=linux GOARCH=arm CGO_ENABLED=1 go install ...
# runtime/cgo
clang: error: argument unused during compilation: '-mno-thumb' [-Werror,-Wunused-command-line-argument]
$ GOOS=linux GOARCH=arm CGO_ENABLED=1 CGO_CFLAGS="-Wno-unused-command-line-argument" go install ...
# runtime/cgo
In file included from _cgo_export.c:3:
cgo-gcc-export-header-prolog:25:55: error: '_check_for_32_bit_pointer_matching_GoInt' declared as an array with a negative size
Does anybody have a solution for this? Trying to avoid compling directly on ARM,
@peterdeka You'd need to install a C cross-compiler. The reason this fails is that zmq4 is a wrapper over the C ZeroMQ library, which must also be compiled. Setting up a C cross-compiler is a serious pain and it would generally be easier to compile natively on ARM.
I have found a solution that might help: indeed a cross-compiler for the target architecture is needed, and you should have also cross-compiled zmq before.
I am currently using this script to compile (my target architecture is ARMv7):
#!/bin/bash
ARM_PREFIX="arm-linux-gnueabihf-"
TOOLCHAIN_PATH="/path/to/your/toolchain"
CC="${TOOLCHAIN_PATH}/bin/${ARM_PREFIX}gcc" \
CFLAGS="-march=armv7-a -mfpu=neon" \
GOOS=linux \
GOARCH=arm \
GOARM=7 \
CGO_ENABLED=1 \
PKG_CONFIG_PATH="${TOOLCHAIN_PATH}/lib/pkgconfig" \
go build
Just be careful that the paths defined for pkg-config
to find in ${TOOLCHAIN_PATH}/lib/pkg-config/libzmq.pc
are correct.
I can confirm that @marcoreato's solution works. I've created a docker image for armv7 cross compilation with static linking. Source is here: https://github.com/farshidtz/zmq4-arm
Hi @pebbe ,
I am trying to build my GO SDK which is written on the top of zmq4 for ARM architecture. But I am getting the following error:
Also I tried for:
GOOS=linux
GOARCH=arm64 go buildBut I got the same error.
Machine Info: Linux 14.04 [64-bit] GO version : go1.9 linux/amd64
Can you please let me know whether it is possible to build zmq4 for arm architecture. and what is the pre-requisites to do so.