I installed zmq on my linux-ubuntu flavoured NVIDIA Jetson Xavier as follows:
sudo apt-get install libzmq3-dev
I created a simple ZMQ server that uses PUSH/PULL architecture in a C++ program. I am able to compile it using CLI as follows:
$ gcc -Wall -g server.cpp -lstdc++ -lzmq -o out
Then I integrate this code in my larger application with more libraries and dependencies. This is compiled using a makefile (makefile.config
). To compile the updated application, I need to add the -lzmq
flag to the original makefile. This is what I do:
-COMMON_FLAGS += -Wall -Wno-deprecated-declarations -std=c++11 $(INCPATHS)
+COMMON_FLAGS += -Wall -g -lstdc++ -lzmq -Wno-deprecated-declarations -std=c++11 $(INCPATHS)
But on running sudo make clean && sudo make
, I get
Linking: ../../bin/sample_uff_mask_rcnn_debug
../../bin/dchobj/sampleUffMaskRCNN.o: In function `main':
/home/virus/Desktop/optimisation/custom-inference-mrcnn/maskRCNN/sampleUffMaskRCNN.cpp:717: undefined reference to `zmq_ctx_new'
/home/virus/Desktop/optimisation/custom-inference-mrcnn/maskRCNN/sampleUffMaskRCNN.cpp:718: undefined reference to `zmq_socket'
/home/virus/Desktop/optimisation/custom-inference-mrcnn/maskRCNN/sampleUffMaskRCNN.cpp:724: undefined reference to `zmq_ctx_new'
/home/virus/Desktop/optimisation/custom-inference-mrcnn/maskRCNN/sampleUffMaskRCNN.cpp:725: undefined reference to `zmq_socket'
/home/virus/Desktop/optimisation/custom-inference-mrcnn/maskRCNN/sampleUffMaskRCNN.cpp:726: undefined reference to `zmq_connect'
/home/virus/Desktop/optimisation/custom-inference-mrcnn/maskRCNN/sampleUffMaskRCNN.cpp:737: undefined reference to `zmq_recv'
collect2: error: ld returned 1 exit status
../Makefile.config:301: recipe for target '../../bin/sample_uff_mask_rcnn_debug' failed
make: *** [../../bin/sample_uff_mask_rcnn_debug] Error 1
The Makefile is simple
OUTNAME_RELEASE = sample_uff_mask_rcnn
OUTNAME_DEBUG = sample_uff_mask_rcnn_debug
EXTRA_DIRECTORIES = ../common
.NOTPARALLEL:
MAKEFILE ?= ../Makefile.config
include $(MAKEFILE)
The original makefile.config
can be found here
I feel that I am messing up with the makefile because zmq works when compiling using gcc
.
Ok so as @madscientist pointed out, I was wrongly adding the linker flag -lzmq
to the compiler line, which was meant to only contain compilation flags and not linker flags.
This is the change I made:
COMMON_LIBS += $(CUDART_LIB)
+COMMON_LIBS += -lzmq