Hello;
I am having trouble to use OpenCV during “make” command. The code I try to run is gst-nvinfer-custome. The Makefile included this line for calling OpenCV “PKGS:= gstreamer-1.0 gstreamer-base-1.0 gstreamer-video-1.0 /usr/lib/x86_64-linux-gnu/pkgconfig/opencv4.pc” code line. It gave me an error of opencv4.pc file not found.
I found a suggestion from mehematdeniz and modify the “Makerfile” but it looks like still not able to find OpenCV.
Here is the Makefile (I don’t have access to “CMakeLists.txt” file):
################################################################################
# Copyright (c) 2017-2022, NVIDIA CORPORATION. All rights reserved.
#
# NVIDIA Corporation and its licensors retain all intellectual property
# and proprietary rights in and to this software, related documentation
# and any modifications thereto. Any use, reproduction, disclosure or
# distribution of this software and related documentation without an express
# license agreement from NVIDIA Corporation is strictly prohibited.
#################################################################################
#
CUDA_VER?=
ifeq ($(CUDA_VER),)
$(error "CUDA_VER is not set")
endif
OPENCV = 1
GPU = 1
CXX:= g++
SRCS:= gstnvinfer.cpp gstnvinfer_allocator.cpp gstnvinfer_property_parser.cpp \
gstnvinfer_meta_utils.cpp gstnvinfer_impl.cpp gstnvinfer_yaml_parser.cpp \
align_functions.cpp tensor_extractor.cpp
INCS:= $(wildcard *.h)
LIB:=libnvdsgst_infer.so
NVDS_VERSION:=6.1
CFLAGS+= -fPIC -std=c++11 -DDS_VERSION=\"6.1.0\" \
-I /usr/local/cuda-$(CUDA_VER)/include \
-I /opt/nvidia/deepstream/deepstream-6.1/sources/includes \
-I /opt/nvidia/deepstream/deepstream-6.1/sources/gst-plugins/gst-nvdspreprocess/include \
-I /opt/nvidia/deepstream/deepstream-6.1/sources/libs/nvdsinfer -DNDEBUG
-D_GLIBCXX_USE_CXX11_ABI=0
CFLAGS+=-I /usr/include/opencv4
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
LIBS+= -L$(LIB_INSTALL_DIR) -lnvdsgst_helper -lnvdsgst_meta -lnvds_meta \
-lnvds_infer -lnvbufsurface -lnvbufsurftransform -ldl -lpthread -lyaml-cpp \
-lcuda -Wl,-rpath,$(LIB_INSTALL_DIR)
OBJS:= $(SRCS:.cpp=.o)
# PKGS:= gstreamer-1.0 gstreamer-base-1.0 gstreamer-video-1.0 /usr/lib/x86_64-linux-gnu/pkgconfig/opencv4.pc
PKGS:= gstreamer-1.0 gstreamer-base-1.0 gstreamer-video-1.0
CFLAGS+=$(shell pkg-config --cflags $(PKGS))
LIBS+=$(shell pkg-config --libs $(PKGS))
# Error in OpenCV in Nivida AGX Orin
# ref: https://forums.developer.nvidia.com/t/opencv-no-package-opencv-found/169616/2?u=cloudlakecho
ifeq ($(OPENCV), 1)
COMMON+= -DOPENCV
CFLAGS+= -DOPENCV
LDFLAGS+= `pkg-config --libs opencv4` -lstdc++
COMMON+= `pkg-config --cflags opencv4`
endif
ifeq ($(GPU), 1)
COMMON+= -DGPU -I/usr/local/cuda/include/ -I/usr/local/cuda/targets/aarch64-linux/include/
CFLAGS+= -DGPU
LDFLAGS+= -L/usr/lib/aarch64-linux-gnu -lcuda -lcudart -lcublas -lcurand
endif
#
all: $(LIB)
%.o: %.cpp $(INCS) Makefile
$(CXX) -c -o $@ $(CFLAGS) $<
$(LIB): $(OBJS) $(DEP) Makefile
$(CXX) -o $@ $(OBJS) $(LIBS)
install: $(LIB)
cp -rv $(LIB) $(GST_INSTALL_DIR)
clean:
rm -rf $(OBJS) $(LIB)
This is at the end of error log (log is too long, so I don’t want to show in here, but entire log - to read please use Chrome browser):
/usr/bin/ld: align_functions.cpp:(.text._ZN2cv4Mat_IhEaSEONS_3MatE[_ZN2cv4Mat_IhEaSEONS_3MatE]+0xcc): undefined reference to `cv::Mat::operator=(cv::Mat&&)'
/usr/bin/ld: align_functions.cpp:(.text._ZN2cv4Mat_IhEaSEONS_3MatE[_ZN2cv4Mat_IhEaSEONS_3MatE]+0xd4): undefined reference to `cv::Mat::~Mat()'
/usr/bin/ld: align_functions.cpp:(.text._ZN2cv4Mat_IhEaSEONS_3MatE[_ZN2cv4Mat_IhEaSEONS_3MatE]+0x110): undefined reference to `cv::Mat::convertTo(cv::_OutputArray const&, int, double, double) const'
/usr/bin/ld: align_functions.cpp:(.text._ZN2cv4Mat_IhEaSEONS_3MatE[_ZN2cv4Mat_IhEaSEONS_3MatE]+0x14c): undefined reference to `cv::Mat::~Mat()'
/usr/bin/ld: align_functions.o: in function `cv::Mat_<unsigned char>::release()':
align_functions.cpp:(.text._ZN2cv4Mat_IhE7releaseEv[_ZN2cv4Mat_IhE7releaseEv]+0x10): undefined reference to `cv::Mat::release()'
collect2: error: ld returned 1 exit status
make: *** [Makefile:81: libnvdsgst_infer.so] Error 1
Any suggestion appreciated.
Thank You.
My runtime environment:
Hardware: Nvidia Orin
OS: Ubuntu 20.04 on AArch 64 processor (not x86_64 or Amd)