pebbe / zmq4

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

Static linking with Drafts #127

Closed sysbot closed 6 years ago

sysbot commented 6 years ago

I am able to statically link zmq4 with golang but unable to get the draft code path working. Currently I'm successfully build with

CGO_CPPFLAGS="-I/usr/include" CGO_LDFLAGS="-L/usr/lib -L/usr/lib/x86_64-linux-gnu -lzmq -lpthread -lsodium -lrt -lstdc++ -lm -lc -lgcc" go build -v --ldflags "-v '-extldflags=-v -static -Wl,--allow-multiple-definition,--verbose=99'" -a main.go

Using shared libzmq, it seemed nothing else is need to use the draft code.

Looking at the code, I notice that ZMQ_BUILD_DRAFT_API is required so I've been trying to pass in ZMQ_BUILD_DRAFT_API via CGO_CFLAGS but so far unable to get it working. I'm unable to find any docs in zmq4 that made reference to draft built, where this is listed in goczmq[1]

CGO_CPPFLAGS="-I/usr/include" CGO_CFLAGS="-DZMQ_BUILD_DRAFT_API=1 -I/usr/local/include -L/usr/local/lib -lzmq" CGO_LDFLAGS="-L/usr/lib -L/usr/lib/x86_64-linux-gnu -lzmq -lpthread -lsodium -lrt -lstdc++ -lm -lc -lgcc" go build -v --ldflags "-v '-extldflags=-v -static -Wl,--allow-multiple-definition,--verbose=99'" -tags draft -a ./cmd/shepard

I'm currently using libzmq with:

CFLAGS="-DZMQ_BUILD_DRAFT_API=1" ./configure --enable-drafts --enable-static --with-libsodium

Any help is appreciated.

[1] https://github.com/zeromq/goczmq/commit/b9c1810fe73eb83b6fb0f643810beb1ca8bd55f4#diff-04c6e90faac2675aa89e2176d2eec7d8

sysbot commented 6 years ago

Looked to be an issue on my end. The libzmq i was using was HEAD which is currently 4.3.1, draft required 4.2