Compilation of nvidia plugins

I attempted to compile the downloaded source code of the NVIDIA plugins on a dGPU using the provided makefile. The system setup I used for compilation is as follows:

  • Hardware Platform (GPU)
  • DeepStream Version: 6.1
  • TensorRT Version: 8.4.1
  • NVIDIA GPU Driver Version: 515.86.01

Specifically, I focused on compiling the nvvideo4linux2 plugin using the given makefile.

SO_NAME := libgstnvvideo4linux2.so

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

NVDS_VERSION:=6.1

ifeq ($(TARGET_DEVICE),aarch64)
GST_INSTALL_DIR?=/usr/lib/aarch64-linux-gnu/gstreamer-1.0/
LIB_INSTALL_DIR?=/usr/lib/aarch64-linux-gnu/tegra/

LIBS:= -lnvbuf_utils -lnvbufsurface
else
GST_INSTALL_DIR?=/opt/nvidia/deepstream/deepstream-$(NVDS_VERSION)/lib/gst-plugins/
LIB_INSTALL_DIR?=/opt/nvidia/deepstream/deepstream-$(NVDS_VERSION)/lib/
CFLAGS:= -DUSE_V4L2_TARGET_NV_CODECSDK=1
LIBS:= -lnvbufsurface
endif

SRCS := $(wildcard *.c)
INCS:= $(wildcard *.h)
INCLUDES += -I…/include
-I/usr/lib/x86_64-linux-gnu/glib-2.0/include
-I…/…/include

PKGS := gstreamer-1.0
gstreamer-base-1.0
gstreamer-video-1.0
gstreamer-allocators-1.0
glib-2.0
libv4l2

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

CFLAGS += -fPIC
-DEXPLICITLY_ADDED=1
-DGETTEXT_PACKAGE=1
-DHAVE_LIBV4L2=1
-DUSE_V4L2_TARGET_NV=1
pkg-config --cflags $(PKGS)
-I/usr/local/cuda-11.6/include
-I/usr/include/gstreamer-1.0
-I/opt/nvidia/deepstream/deepstream-6.1/sources/includes
-I/opt/nvidia/deepstream/deepstream-6.1/sources/libs \

LDFLAGS = -Wl,–no-undefined -L$(LIB_INSTALL_DIR) -Wl,-rpath,$(LIB_INSTALL_DIR)

LIBS := -shared -Wl,-no-undefined
-L/usr/local/cuda-11.6/lib64
-lcudart
-L/opt/nvidia/deepstream/deepstream-6.1/sources/lib -lnvbufsurface
-L/opt/nvidia/deepstream/deepstream-6.1/sources/lib -lnvbufsurftransform
-L/opt/nvidia/deepstream/deepstream-6.1/lib/ -lnvdsbufferpool
-L/lib/x86_64-linux-gnu/gstreamer-1.0
pkg-config --libs $(PKGS)
-L$(LIB_INSTALL_DIR) -lnvdsgst_helper -lnvdsgst_meta -lnvds_meta
-lnvds_infer -lnvbufsurface -lnvdsbufferpool -lnvbufsurftransform -ldl -lpthread -lyaml-cpp
-lcuda -Wl,-rpath,$(LIB_INSTALL_DIR)

PKGS:= gstreamer-1.0 gstreamer-base-1.0 gstreamer-video-1.0
CFLAGS+=$(shell pkg-config --cflags $(PKGS))
LIBS+=$(shell pkg-config --libs $(PKGS))

all: $(SO_NAME)

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

$(SO_NAME): $(OBJS)
$(CC) -shared -o $(SO_NAME) $(OBJS) $(LIBS) $(LDFLAGS)

.PHONY: install
install: $(SO_NAME)
cp -vp $(SO_NAME) $(GST_INSTALL_DIR)

.PHONY: clean
clean:
rm -rf $(OBJS) $(SO_NAME)

During the compilation process, I encountered several issues. Here are the specific problems I encountered:

/bin/ld: gstv4l2bufferpool.o: in function gst_v4l2_buffer_pool_copy_buffer': gstv4l2bufferpool.c:(.text+0x96c): undefined reference to NvBufferMemMap’
/bin/ld: gstv4l2bufferpool.c:(.text+0xa9d): undefined reference to NvBufferMemUnMap' /bin/ld: gstv4l2bufferpool.c:(.text+0xcd4): undefined reference to ExtractFdFromNvBuffer’
/bin/ld: gstv4l2bufferpool.c:(.text+0xd95): undefined reference to NvBufferTransform' /bin/ld: gstv4l2bufferpool.o: in function gst_v4l2_buffer_pool_import_dmabuf’:
gstv4l2bufferpool.c:(.text+0x1b1d): undefined reference to ExtractFdFromNvBuffer' /bin/ld: gstv4l2allocator.o: in function gst_v4l2_allocator_alloc_mmap’:
gstv4l2allocator.c:(.text+0x2545): undefined reference to NvBufferGetParams' /bin/ld: gstv4l2allocator.o: in function gst_v4l2_allocator_dqbuf’:
gstv4l2allocator.c:(.text+0x45cd): undefined reference to `NvBufferGetSize’
collect2: error: ld returned 1 exit status
make: *** [Makefile:87: libgstnvvideo4linux2.so] Error 1.

You can find the source code for C/C++ sample applications on NVIDIA’s website. It provides detailed information about the source code.

At the bottom of the page, you will find footnotes that offer the source code for plugins that are not open source. These footnotes provide access to the necessary source code for those specific plugins.

Footnotes:
Gst-v4l2 sources are not present in DeepStream package. To download, follow these steps:

  1. Go to: Jetson Download Center | NVIDIA Developer.
  2. In the Search filter field, enter L4T
  3. Select the appropriate item for L4T Release 35.2.1.
  4. Search for L4T Driver Package (BSP) Sources
  5. Download the file and un-tar it, to get the .tbz2 file.
  6. Expand the .tbz2 file. Gst-v4l2 source files are in gst-nvvideo4linux2_src.tbz2. libnvv4l2 sources are present in v4l2_libs_src.tbz2.

Because this is an open source of Jetson, there are quite a few differences in the dependency environment on DGPU. We don’t recommend that you do this.
You also need to consider the issue of version uniformity, like DeepStream version, CUDA version, Jetpack version, Driver version. If you encounter any problems during the real scenarios, you can file a topic related to the problem.

Should I try compiling it on a Jetson device?

There is no update from you for a period, assuming this is not an issue anymore. Hence we are closing this topic. If need further support, please open a new one. Thanks

You can try that. And you need to ensure the consistency of the other software version. You can refer to the link below to get the version of softwares: https://docs.nvidia.com/metropolis/deepstream/dev-guide/text/DS_Quickstart.html#platform-and-os-compatibility

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