Building zeromq
Closed this issue · 3 comments
I am trying to build zeromq4 along with a go package for it.
As a prerequisite I built libsodium:
wget https://download.libsodium.org/libsodium/releases/libsodium-1.0.8.tar.gz
tar xzvf libsodium-1.0.8.tar.gz
cd libsodium-1.0.8/
./configure --disable-shared --host=x86_64-rumprun-netbsd
make
sudo su
make install
and then zeromq4:
wget http://download.zeromq.org/zeromq-4.1.4.tar.gz
tar xzvf zeromq-4.1.4.tar.gz
cd zeromq-4.1.4/
./configure --disable-shared --host=x86_64-rumprun-netbsd
make
sudo make install
both of those went fine.
I then tried to build https://github.com/pebbe/zmq4:
CC=x86_64-rumprun-netbsd-gcc CGO_ENABLED=1 GOOS=rumprun /home/ubuntu/gorump/go/bin/go build -x -a --ldflags '-extldflags "-lstdc++ -static"'
but I ran into issues with c++ stdlib:
/tmp/go-build172868367/github.com/pebbe/zmq4/_obj/_cgo_.o: In function `zmq_ctx_new':
/home/ubuntu/gorump/examples/zeromq/zeromq-4.1.4/src/zmq.cpp:155: undefined reference to `std::nothrow'
/home/ubuntu/gorump/examples/zeromq/zeromq-4.1.4/src/zmq.cpp:155: undefined reference to `operator new(unsigned long, std::nothrow_t const&)'
/home/ubuntu/gorump/examples/zeromq/zeromq-4.1.4/src/zmq.cpp:155: undefined reference to `std::nothrow'
/home/ubuntu/gorump/examples/zeromq/zeromq-4.1.4/src/zmq.cpp:155: undefined reference to `operator delete(void*, std::nothrow_t const&)'
/home/ubuntu/gorump/examples/zeromq/zeromq-4.1.4/src/zmq.cpp:155: undefined reference to `_Unwind_Resume'
and a bunch more of those, all related to the fact that gcc can't link with libstdc++...
Also examining commands I can see that for some reason my linker argument -lstdc++ has no effect:
x86_64-rumprun-netbsd-gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -print-libgcc-file-name
x86_64-rumprun-netbsd-gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -I $WORK/runtime/cgo/_obj/ -g -O2 -Wall -Werror -o $WORK/runtime/cgo/_obj/_cgo_main.o -c $WORK/runtime/cgo/_obj/_cgo_main.c
x86_64-rumprun-netbsd-gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -I $WORK/runtime/cgo/_obj/ -g -O2 -Wall -Werror -o $WORK/runtime/cgo/_obj/_cgo_export.o -c $WORK/runtime/cgo/_obj/_cgo_export.c
x86_64-rumprun-netbsd-gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -I $WORK/runtime/cgo/_obj/ -g -O2 -Wall -Werror -o $WORK/runtime/cgo/_obj/cgo.cgo2.o -c $WORK/runtime/cgo/_obj/cgo.cgo2.c
x86_64-rumprun-netbsd-gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -I $WORK/runtime/cgo/_obj/ -g -O2 -Wall -Werror -o $WORK/runtime/cgo/_obj/gcc_libinit.o -c ./gcc_libinit.c
x86_64-rumprun-netbsd-gcc -I . -fPIC -m64 -pthread -fmessage-length=0 -I $WORK/runtime/cgo/_obj/ -g -O2 -Wall -Werror -o $WORK/runtime/cgo/_obj/gcc_rumprun_amd64.o -c ./gcc_rumprun_amd64.c
Any advice?
By the way, if I try to build the go zmq package with g++ (x86_64-rumprun-netbsd-g++) which would probably make more sense, I get issues like error: invalid conversion from ‘void*’ to ‘const char*’ [-fpermissive]
I haven't touched 0mq for quite some time but libsodium is c, 0mq is c++ and both of these are linking errors, have you looked into using the pure go instead? https://github.com/zeromq/gomq - not only do you not have to deal w/the linking mess but performance wise you are going to be much better off
I guess you're right, I've been battling this for the last 6 without much luck. I got both 0mq and czmq working fine in a rumpkernel from C++ but with Go no luck.
I honestly wasn't aware of gomq, I'll probably go with it - no sense pushing for this issue.
Thanks for the suggestion and most of all - thanks for gorump :)