Undefined reference to `NvBufSurfaceMap'

• Jetson AGX Xavier
• Deepstream 6.0
• JetPack 4.6
• TensorRT 8.0.1
• NVIDIA GPU Driver 32.6.1

Hi, i’m trying to get an image in deepstream-app
but on compiling the application I got these errors:

**g++ -o deepstream-app ../src/deepstream_app.o ../src/cosine_similarity.o ../src/deepstream_app_main.o ../src/deepstream_app_config_parser.o /opt/nvidia/deepstream/deepstream-6.0/sources/apps/apps-
common/src/deepstream_tracker_bin.o /opt/nvidia/deepstream/deepstream-6.0/sources/apps/apps-
common/src/deepstream_primary_gie_bin.o /opt/nvidia/deepstream/deepstream-6.0/sources/apps/apps-
common/src/deepstream_source_bin.o /opt/nvidia/deepstream/deepstream-6.0/sources/apps/apps-
common/src/deepstream_audio_classifier_bin.o /opt/nvidia/deepstream/deepstream-6.0/sources/apps/apps-
common/src/deepstream_c2d_msg.o /opt/nvidia/deepstream/deepstream-6.0/sources/apps/apps-
common/src/deepstream_config_file_parser.o /opt/nvidia/deepstream/deepstream-6.0/sources/apps/apps-
common/src/deepstream_preprocess.o /opt/nvidia/deepstream/deepstream-6.0/sources/apps/apps-
common/src/deepstream_common.o /opt/nvidia/deepstream/deepstream-6.0/sources/apps/apps-
common/src/deepstream_sink_bin.o /opt/nvidia/deepstream/deepstream-6.0/sources/apps/apps-
common/src/deepstream_perf.o /opt/nvidia/deepstream/deepstream-6.0/sources/apps/apps-
common/src/deepstream_dewarper_bin.o /opt/nvidia/deepstream/deepstream-6.0/sources/apps/apps-
common/src/deepstream_dsexample.o /opt/nvidia/deepstream/deepstream-6.0/sources/apps/apps-
common/src/deepstream_secondary_gie_bin.o /opt/nvidia/deepstream/deepstream-6.0/sources/apps/apps-
common/src/deepstream_dsanalytics.o /opt/nvidia/deepstream/deepstream-6.0/sources/apps/apps-
common/src/deepstream_tiled_display_bin.o /opt/nvidia/deepstream/deepstream-6.0/sources/apps/apps-
common/src/deepstream_c2d_msg_util.o /opt/nvidia/deepstream/deepstream-6.0/sources/apps/apps-
common/src/deepstream_osd_bin.o /opt/nvidia/deepstream/deepstream-6.0/sources/apps/apps-
common/src/deepstream_streammux.o -L/opt/nvidia/deepstream/deepstream-6.0/lib/ -lnvdsgst_meta -
lnvds_meta -lnvdsgst_helper -lnvdsgst_smartrecord -lcurl -lnvds_utils -lnvds_msgbroker -lm -lgstrtspserver-
1.0 -ldl -Wl,-rpath,/opt/nvidia/deepstream/deepstream-6.0/lib/ -L/usr/local/cuda/lib64/ -lcuda -lcudart -
lcublasLt  `pkg-config --libs gstreamer-1.0 gstreamer-video-1.0 x11 json-glib-1.0 opencv4`
../src/deepstream_app_main.o: In function `all_bbox_generated(_AppCtx*, _GstBuffer*, _NvDsBatchMeta*, 
unsigned int)':
deepstream_app_main.c:(.text+0x918): undefined reference to `NvBufSurfaceMap'
deepstream_app_main.c:(.text+0x928): undefined reference to `NvBufSurfaceSyncForCpu'
collect2: error: ld returned 1 exit status
Makefile:67: recipe for target 'deepstream-app' failed
make: *** [deepstream-app] Error 1**

Here is makefile:


CC=g++
CFLAGS:= -Wall -std=c++11
CFLAGS+= -shared -fPIC -fpermissive

APP:= deepstream-app

TARGET_DEVICE = $(shell $(CC) -dumpmachine | cut -f1 -d -)

NVDS_VERSION:=6.0
LIB_INSTALL_DIR?=/opt/nvidia/deepstream/deepstream-$(NVDS_VERSION)/lib/

ifeq ($(TARGET_DEVICE),aarch64)
  CFLAGS+= -DPLATFORM_TEGRA
endif

SRCS:= $(wildcard ../src/*.c)
SRCS+= $(wildcard /opt/nvidia/deepstream/deepstream-$(NVDS_VERSION)/sources/apps/apps-common/src/*.c)

INCS:= $(wildcard ../src/*.h)

PKGS:= gstreamer-1.0 gstreamer-video-1.0 x11 json-glib-1.0 opencv4

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

CFLAGS+= -I./ -I/opt/nvidia/deepstream/deepstream-$(NVDS_VERSION)/sources/apps/apps-common/includes -I/opt/nvidia/deepstream/deepstream/sources/includes -DDS_VERSION_MINOR=0 -DDS_VERSION_MAJOR=6 \
	 -I/usr/local/cuda/include

LDFLAGS=-L/usr/local/cuda/lib64

LIBS+= -L$(LIB_INSTALL_DIR) -lnvdsgst_meta -lnvds_meta -lnvdsgst_helper -lnvdsgst_smartrecord -lcurl -lnvds_utils -lnvds_msgbroker -lm \
       -lgstrtspserver-1.0 -ldl -Wl,-rpath,$(LIB_INSTALL_DIR) \
       -L/usr/local/cuda/lib64/ -lcuda -lcudart -lcublasLt \
	   

CFLAGS+= `pkg-config --cflags $(PKGS)`

LIBS+= `pkg-config --libs $(PKGS)`

all: $(APP)

%.o: %.c $(INCS) Makefile
	$(CC) -c -o $@ $(CFLAGS) $<

$(APP): $(OBJS) Makefile
	$(CC) -o $(APP) $(OBJS) $(LIBS)

install: $(APP)

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

I added cuda as you see

Never mind. I needed to add

-lnvbufsurface

to LIBS in Makefile