Hi all,
Environment :
Jetpack : 5.1
Board : NVIDIA Jetson AGX Orin
I’m developing a developing a custom application using LibArgus library on Jetson.
For my application I am using the sample applications from /usr/src/jetson_multimedia_api/samples and modifying them for me requirements. I am able to copy the sample applications to any location on the Jetson (say $HOME/Documents) and build the sample applications using the provided Makefile and Rules.mk file.
I would like to use CMakeLists.txt instead. Following the steps from topics on this forum I was able to create a CMakeLists file.
cmake_minimum_required(VERSION 3.5)
project(argus_camera_recording)
set(CMAKE_CXX_STANDARD 11)
find_path(ARGUS_INCLUDE_DIR Argus/Argus.h HINTS "/usr/src/jetson_multimedia_api/argus/include")
set(CMAKE_MODULE_PATH "/usr/src/jetson_multimedia_api/argus/cmake" "${CMAKE_MODULE_PATH}")
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake" "${CMAKE_MODULE_PATH}")
find_package(Argus REQUIRED)
find_package(OpenGLES REQUIRED)
find_package(EGL REQUIRED)
find_package( OpenCV REQUIRED )
include_directories(SYSTEM ${ARGUS_INCLUDE_DIR} ${EGL_INCLUDE_DIR} ${OPENGLES_INCLUDE_DIR} ${OpenCV_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/samples/utils)
pkg_check_modules(GSTREAMER REQUIRED gstreamer-1.0)
include_directories(${GSTREAMER_INCLUDE_DIRS})
add_executable(${PROJECT_NAME} main.cpp)
target_link_libraries( ${PROJECT_NAME} /usr/lib/x86_64-linux-gnu/libcuinj64.so ${OpenCV_LIBS} ${ARGUS_LIBRARIES} ${OPENGLES_LIBRARIES} ${GSTREAMER_LIBRARIES})
While the cmake . command executes without any errors being generated, the make command generates the following error:
/home/nvidia/Documents/CameraVideo/test1/main.cpp:29:10: fatal error: Error.h: No such file or directory
29 | #include "Error.h"
| ^~~~~~~~~
compilation terminated.
It is not able to find the Error.h file located in /usr/src/jetson_multimedia_api/argus/samples/utils.
Any guidance on getting a CMakeLists.txt file?
Here is the Makefile and Rules.mk file for the camera recording sample application (Jetson Linux API Reference: 10_camera_recording (libargus capture) | NVIDIA Docs) that came with the Argus library and is at /usr/src/jetson_multimedia_api/samples/10_camera_recording
Makefile
###############################################################################
#
# Copyright (c) 2016-2018, NVIDIA CORPORATION. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of NVIDIA CORPORATION nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
###############################################################################
include Rules.mk
APP := argus_camera_recording
TOP_DIR := /usr/src/jetson_multimedia_api
ARGUS_UTILS_DIR := $(TOP_DIR)/argus/samples/utils
SRCS := \
main.cpp \
$(wildcard $(CLASS_DIR)/*.cpp) \
$(ARGUS_UTILS_DIR)/Thread.cpp \
$(ARGUS_UTILS_DIR)/NativeBuffer.cpp \
$(ARGUS_UTILS_DIR)/nvmmapi/NvNativeBuffer.cpp
OBJS := $(SRCS:.cpp=.o)
CPPFLAGS += \
-I"$(ARGUS_UTILS_DIR)"
LDFLAGS += \
-lnveglstream_camconsumer -lnvargus_socketclient
all: $(APP)
$(CLASS_DIR)/%.o: $(CLASS_DIR)/%.cpp
$(AT)$(MAKE) -C $(CLASS_DIR)
%.o: %.cpp
@echo "Compiling: $<"
$(CPP) $(CPPFLAGS) -c $< -o $@
$(APP): $(OBJS)
@echo "Linking: $@"
$(CPP) -o $@ $(OBJS) $(CPPFLAGS) $(LDFLAGS)
clean:
$(AT)rm -rf $(APP) $(OBJS)
Rules.mk
###############################################################################
#
# Copyright (c) 2016-2022, NVIDIA CORPORATION. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of NVIDIA CORPORATION nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
###############################################################################
# Clear the flags from env
CPPFLAGS :=
LDFLAGS :=
# Verbose flag
ifeq ($(VERBOSE), 1)
AT =
else
AT = @
endif
# ARM ABI of the target platform
ifeq ($(TEGRA_ARMABI),)
TEGRA_ARMABI ?= aarch64-linux-gnu
endif
# Location of the target rootfs
ifeq ($(shell uname -m), aarch64)
TARGET_ROOTFS :=
else
ifeq ($(TARGET_ROOTFS),)
$(error Please specify the target rootfs path if you are cross-compiling)
endif
endif
# Location of the CUDA Toolkit
CUDA_PATH := /usr/local/cuda
# Use absolute path for better access from everywhere
#TOP_DIR := $(shell pwd | awk '{split($$0, f, "/samples"); print f[1]}')
TOP_DIR := /usr/src/jetson_multimedia_api
CLASS_DIR := $(TOP_DIR)/samples/common/classes
ALGO_CUDA_DIR := $(TOP_DIR)/samples/common/algorithm/cuda
ALGO_TRT_DIR := $(TOP_DIR)/samples/common/algorithm/trt
ifeq ($(shell uname -m), aarch64)
CROSS_COMPILE :=
else
CROSS_COMPILE ?= aarch64-unknown-linux-gnu-
endif
AS = $(AT) $(CROSS_COMPILE)as
LD = $(AT) $(CROSS_COMPILE)ld
CC = $(AT) $(CROSS_COMPILE)gcc
CPP = $(AT) $(CROSS_COMPILE)g++
AR = $(AT) $(CROSS_COMPILE)ar
NM = $(AT) $(CROSS_COMPILE)nm
STRIP = $(AT) $(CROSS_COMPILE)strip
OBJCOPY = $(AT) $(CROSS_COMPILE)objcopy
OBJDUMP = $(AT) $(CROSS_COMPILE)objdump
NVCC = $(AT) $(CUDA_PATH)/bin/nvcc -ccbin $(filter-out $(AT), $(CPP))
# Specify the logical root directory for headers and libraries.
ifneq ($(TARGET_ROOTFS),)
CPPFLAGS += --sysroot=$(TARGET_ROOTFS)
LDFLAGS += \
-Wl,-rpath-link=$(TARGET_ROOTFS)/lib/$(TEGRA_ARMABI) \
-Wl,-rpath-link=$(TARGET_ROOTFS)/usr/lib/$(TEGRA_ARMABI) \
-Wl,-rpath-link=$(TARGET_ROOTFS)/usr/lib/$(TEGRA_ARMABI)/tegra \
-Wl,-rpath-link=$(TARGET_ROOTFS)/$(CUDA_PATH)/lib64
endif
# All common header files
CPPFLAGS += -std=c++11 \
-I"$(TOP_DIR)/include" \
-I"$(TOP_DIR)/include/libjpeg-8b" \
-I"$(ALGO_CUDA_DIR)" \
-I"$(ALGO_TRT_DIR)" \
-I"$(TARGET_ROOTFS)/$(CUDA_PATH)/include" \
-I"$(TARGET_ROOTFS)/usr/include/$(TEGRA_ARMABI)" \
-I"$(TARGET_ROOTFS)/usr/include/libdrm" \
-I"$(TARGET_ROOTFS)/usr/include/opencv4"
# All common dependent libraries
LDFLAGS += \
-lpthread -lv4l2 -lEGL -lGLESv2 -lX11 \
-lnvbufsurface -lnvbufsurftransform -lnvjpeg -lnvosd -ldrm \
-lcuda -lcudart \
-L"$(TARGET_ROOTFS)/$(CUDA_PATH)/lib64" \
-L"$(TARGET_ROOTFS)/usr/lib/$(TEGRA_ARMABI)" \
-L"$(TARGET_ROOTFS)/usr/lib/$(TEGRA_ARMABI)/tegra"