pebbe / zmq4

A Go interface to ZeroMQ version 4
BSD 2-Clause "Simplified" License
1.17k stars 166 forks source link

Whether pebbe/zmqt support ARM cpu and ubuntu 16.04 profile #162

Open eyauwag opened 4 years ago

eyauwag commented 4 years ago

I want to use pebbe/zmqt on my ARM cpu.But the README.md says "You can't do cross-compilation. That would disable C.". I want to know whether I should give up my attempt to import pebbe/zmqt in my project for ARM environment.

ghost commented 3 years ago

You can do cross compilation, but you need to compile zmq manually, and then add the libzmq version to Go. This is what I use:

CC="/usr/bin/aarch64-linux-gnu-gcc" \
CGO_FLAGS="-I/zmq-arm/include" \
CGO_LDFLAGS="-L/zmq-arm/lib" \
CGO_ENABLED=1 \
GOARCH=arm64 \
GODEBUG=asyncpreemptoff=1 \
go build --ldflags '-linkmode external -extldflags "-static -lstdc++ -z muldefs"'

Where /zmq-arm is a folder with include and lib. Be sure to match the zmq library version to the latest pebbe/zmq4 one. I happened to compile a 4.3.3 library, but (as of today) this repo uses 4.3.2 (available in Go modules), so it will fail on runtime