Tried to compile the custom plugin using the make file from my docker file and got the linking error for -lnvbufsurface and -lnvbufsurftransform

Please provide complete information as applicable to your setup.

• Hardware Platform (Jetson / GPU) : Jetson
• DeepStream Version : 7.0
• JetPack Version (valid for Jetson only) : 6.0
• TensorRT Version
• NVIDIA GPU Driver Version (valid for GPU only)
• Issue Type( questions, new requirements, bugs) : questions
• How to reproduce the issue ? (This is for bugs. Including which sample app is using, the configuration files content, the command line used and other details for reproducing) : Create a docker file using the nvcr.io/nvidia/deepstream:7.0-samples-multiarch base image and try to compile the gstdsexample.cpp using the makefile for the docker environment.
• Requirement details( This is for new requirement. Including the module name-for which plugin or for which sample application, the function description)

Hi,
I have tried to compile the gstdsexample.cpp custom plugin using the make file from my docker file and got the following error:

 => ERROR [runtime 21/29] RUN cd /tmp/zone-mask &&     make install &&     rm -rf /tmp/zone-mask                                                                                                    0.5s
------
 > [runtime 21/29] RUN cd /tmp/zone-mask &&     make install &&     rm -rf /tmp/zone-mask:
0.259 -fPIC -DDS_VERSION="7.0" -I /usr/local/cuda-12.2/include -I /opt/nvidia/deepstream/deepstream-7.0/sources/includes -DWITH_OPENCV -I /usr/include/opencv4 -pthread -I/usr/include/gstreamer-1.0 -I/usr/include/orc-0.4 -I/usr/include/gstreamer-1.0 -I/usr/include/aarch64-linux-gnu -I/usr/include/glib-2.0 -I/usr/lib/aarch64-linux-gnu/glib-2.0/include -I/usr/include/opencv4
0.260 g++ -o libnvdsgst_dsexample.so gstdsexample.o -shared -Wl,-no-undefined -L/usr/local/cuda-12.2/lib64/ -lcudart -ldl -lnppc -lnppig -lnpps -lnppicc -lnppidei -L/opt/nvidia/deepstream/deepstream-7.0/lib/ -lnvdsgst_helper -lnvdsgst_meta -lnvds_meta -lnvbufsurface -lnvbufsurftransform -Wl,-rpath,/opt/nvidia/deepstream/deepstream-7.0/lib/ -lgstvideo-1.0 -lgstbase-1.0 -lgstreamer-1.0 -lgobject-2.0 -lglib-2.0 -lopencv_stitching -lopencv_alphamat -lopencv_aruco -lopencv_barcode -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_dnn_objdetect -lopencv_dnn_superres -lopencv_dpm -lopencv_face -lopencv_freetype -lopencv_fuzzy -lopencv_hdf -lopencv_hfs -lopencv_img_hash -lopencv_intensity_transform -lopencv_line_descriptor -lopencv_mcc -lopencv_quality -lopencv_rapid -lopencv_reg -lopencv_rgbd -lopencv_saliency -lopencv_shape -lopencv_stereo -lopencv_structured_light -lopencv_phase_unwrapping -lopencv_superres -lopencv_optflow -lopencv_surface_matching -lopencv_tracking -lopencv_highgui -lopencv_datasets -lopencv_text -lopencv_plot -lopencv_ml -lopencv_videostab -lopencv_videoio -lopencv_viz -lopencv_wechat_qrcode -lopencv_ximgproc -lopencv_video -lopencv_xobjdetect -lopencv_objdetect -lopencv_calib3d -lopencv_imgcodecs -lopencv_features2d -lopencv_dnn -lopencv_flann -lopencv_xphoto -lopencv_photo -lopencv_imgproc -lopencv_core
0.297 /usr/bin/ld: cannot find -lnvbufsurface: No such file or directory
0.298 /usr/bin/ld: cannot find -lnvbufsurftransform: No such file or directory
0.485 collect2: error: ld returned 1 exit status
0.486 make: *** [Makefile:78: libnvdsgst_dsexample.so] Error 1
------
Dockerfile.edge:209
--------------------
 208 |     
 209 | >>> RUN cd /tmp/zone-mask && \
 210 | >>>     # make && \
 211 | >>>     make install && \
 212 | >>>     # cp -rv libnvdsgst_dsexample.so /opt/nvidia/deepstream/deepstream-7.0/lib/gst-plugins/  && \
 213 | >>>     rm -rf /tmp/zone-mask
 214 |     
--------------------
ERROR: failed to solve: process "/bin/sh -c cd /tmp/zone-mask &&     make install &&     rm -rf /tmp/zone-mask" did not complete successfully: exit code: 2

This is my make file:

WITH_OPENCV=1

CUDA_VER=12.2
ifeq ($(CUDA_VER),)
  $(error "CUDA_VER is not set")
endif
TARGET_DEVICE = $(shell gcc -dumpmachine | cut -f1 -d -)
CXX:= g++

CXXFLAGS+= -v

SRCS:= gstdsexample.cpp


INCS:= $(wildcard *.h)
LIB:=libnvdsgst_dsexample.so

NVDS_VERSION:=7.0


CFLAGS+= -fPIC -DDS_VERSION=\"7.0\" \
	 -I /usr/local/cuda-$(CUDA_VER)/include \
	 -I /opt/nvidia/deepstream/deepstream-7.0/sources/includes

GST_INSTALL_DIR?=/opt/nvidia/deepstream/deepstream-$(NVDS_VERSION)/lib/gst-plugins/
LIB_INSTALL_DIR?=/opt/nvidia/deepstream/deepstream-$(NVDS_VERSION)/lib/

LIBS := -shared -Wl,-no-undefined \
	-L/usr/local/cuda-$(CUDA_VER)/lib64/ -lcudart -ldl \
	-lnppc -lnppig -lnpps -lnppicc -lnppidei \
	-L$(LIB_INSTALL_DIR) -lnvdsgst_helper -lnvdsgst_meta -lnvds_meta -lnvbufsurface -lnvbufsurftransform\
	-Wl,-rpath,$(LIB_INSTALL_DIR)

OBJS:= $(SRCS:.cpp=.o)

PKGS:= gstreamer-1.0 gstreamer-base-1.0 gstreamer-video-1.0

ifeq ($(WITH_OPENCV),1)
CFLAGS+= -DWITH_OPENCV \
 -I /usr/include/opencv4
PKGS+= opencv4
endif

CFLAGS+=$(shell pkg-config --cflags $(PKGS))
LIBS+=$(shell pkg-config --libs $(PKGS))

all: $(LIB)

%.o: %.cpp $(INCS) Makefile
	@echo $(CFLAGS)
	$(CXX) -c -o $@ $(CFLAGS) $<

$(LIB): $(OBJS) $(DEP) Makefile
	@echo $(CFLAGS)
	$(CXX) -o $@ $(OBJS) $(LIBS)

install: $(LIB)
	cp -rv $(LIB) $(GST_INSTALL_DIR)

clean:
	rm -rf $(OBJS) $(LIB)

Since these two -lnvbufsurface and -lnvbufsurftransform are symlinked in the deepstream directory, can they be failing to link ?
It worked outside docker without a problem.

This is my related docker snippet

COPY --from=build /realtime/rtsp_restreamer/plugins/zone-mask /tmp/zone-mask

ENV LD_LIBRARY_PATH=/opt/nvidia/deepstream/deepstream-7.0/lib:$LD_LIBRARY_PATH
RUN ldconfig

RUN cd /tmp/zone-mask && \
    make && \
    make install && \
    rm -rf /tmp/zone-mask

These libraries are shared between host and docker on Jetson.
These libraries exist only on the host, but are only mapped into the container at runtime.
So this means that if you want to use them in the build phase, you need to copy them from the host to the docker image.

Another suggestion is that you can compile it in the host and then copy the application binary to the docker image

Thank you @junshengy . Copying the library files at build stage worked. Tried to copy the compiled plugin. It did not work. Got a warning message saying missing opencv library.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.