【发布时间】:2021-12-26 10:46:50
【问题描述】:
我在我的 linux-ubuntu 风格的 NVIDIA Jetson Xavier 上安装了 zmq,如下所示:
sudo apt-get install libzmq3-dev
我创建了一个简单的 ZMQ 服务器,它在 C++ 程序中使用 PUSH/PULL 架构。我可以使用 CLI 编译它,如下所示:
$ gcc -Wall -g server.cpp -lstdc++ -lzmq -o out
然后我将此代码集成到具有更多库和依赖项的更大应用程序中。这是使用 makefile (makefile.config) 编译的。要编译更新的应用程序,我需要将-lzmq 标志添加到原始makefile。我就是这样做的:
-COMMON_FLAGS += -Wall -Wno-deprecated-declarations -std=c++11 $(INCPATHS)
+COMMON_FLAGS += -Wall -g -lstdc++ -lzmq -Wno-deprecated-declarations -std=c++11 $(INCPATHS)
但是在运行 sudo make clean && sudo make 时,我得到了
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
Makefile 很简单
OUTNAME_RELEASE = sample_uff_mask_rcnn
OUTNAME_DEBUG = sample_uff_mask_rcnn_debug
EXTRA_DIRECTORIES = ../common
.NOTPARALLEL:
MAKEFILE ?= ../Makefile.config
include $(MAKEFILE)
原makefile.config可以找到here
我觉得我弄乱了makefile,因为zmq在使用gcc编译时可以工作。
【问题讨论】:
-
您实际上并未在此处提出问题或显示问题。
-
抱歉错过了。我更新了问题
-
好吧,我们不知道你的 makefile 做了什么。但是,将库添加到名为
COMMON_FLAGS的变量中几乎肯定是错误的,因为它们应该只放入链接行,而不是编译行;INCPATHS的存在意味着这些标志被添加到编译行。其次,库的顺序至关重要:它们必须位于所有目标文件之后。所以简而言之,这是添加链接器选项(如-lzmq)的错误变量。您必须找到包含要链接的库的变量。而且,您不应该将-lstdc++添加到您的链接行。
标签: makefile zeromq jetson-xavier