How to compile and install TensorrtOSS on DRIVE AGX ORIN?

Please provide the following info (tick the boxes after creating this topic):
Software Version
[1] DRIVE OS 6.0.5
DRIVE OS 6.0.4 (rev. 1)
DRIVE OS 6.0.4 SDK
other

Target Operating System
[1] Linux
QNX
other

Hardware Platform
DRIVE AGX Orin Developer Kit (940-63710-0010-D00)
DRIVE AGX Orin Developer Kit (940-63710-0010-C00)
[1] DRIVE AGX Orin Developer Kit (not sure its number)
other

SDK Manager Version
[1] 1.9.10816
other

Host Machine Version
[1] native Ubuntu Linux 20.04 Host installed with SDK Manager
native Ubuntu Linux 20.04 Host installed with DRIVE OS Docker Containers
native Ubuntu Linux 18.04 Host installed with DRIVE OS Docker Containers
other

I am trying to compile and install GitHub - NVIDIA/TensorRT: NVIDIA® TensorRT™, an SDK for high-performance deep learning inference, includes a deep learning inference optimizer and runtime that delivers low latency and high throughput for inference applications..
I tried below command:

cmake -DTRT_LIBPATH=/home/nvidia/TensorRT/ -DTRT_OUT_DIR=pwd/out -DTRT_PLATFORM_ID=aarch64 -DCMAKE_CUDA_COMPILER=/usr/local/cuda/bin/nvcc -DCUDA_VERSION=11.4 -DTRT_LIB_DIR=/lib/aarch64-linux-gnu/ -DCUDNN_LIB=/lib/aarch64-linux-gnu/libcudnn.so -DTENSORRT_LIBRARY_INFER=/lib/aarch64-linux-gnu/libnvinfer.so -DTENSORRT_LIBRARY_INFER_PLUGIN=/lib/aarch64-linux-gnu/libnvinfer_plugin.so …

But it failed and the CMakeError.log is as below:

Compiling the CUDA compiler identification source file “CMakeCUDACompilerId.cu” failed.
Compiler: /usr/local/cuda/bin/nvcc
Build flags: -I/usr/local/cuda-11.4/targets/aarch64-linux/include;-Xcompiler=“-fPIC;”
Id flags: -v;–keep;–keep-dir;tmp;-ccbin=/usr/bin/aarch64-linux-gnu-g++

The output was:
1
nvcc fatal : Stray ‘"’ character

Performing C++ SOURCE FILE Test CMAKE_HAVE_LIBC_PTHREAD failed with the following output:
Change Dir: /home/nvidia/TensorRT/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/make cmTC_99126/fast && /usr/bin/make -f CMakeFiles/cmTC_99126.dir/build.make CMakeFiles/cmTC_99126.dir/build
make[1]: Entering directory ‘/home/nvidia/TensorRT/build/CMakeFiles/CMakeTmp’
Building CXX object CMakeFiles/cmTC_99126.dir/src.cxx.o
/usr/bin/aarch64-linux-gnu-g++ -Wno-deprecated-declarations -DBUILD_SYSTEM=cmake_oss -DCMAKE_HAVE_LIBC_PTHREAD -std=c++14 -o CMakeFiles/cmTC_99126.dir/src.cxx.o -c /home/nvidia/TensorRT/build/CMakeFiles/CMakeTmp/src.cxx
Linking CXX executable cmTC_99126
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_99126.dir/link.txt --verbose=1
/usr/bin/aarch64-linux-gnu-g++ -Wno-deprecated-declarations -DBUILD_SYSTEM=cmake_oss -DCMAKE_HAVE_LIBC_PTHREAD CMakeFiles/cmTC_99126.dir/src.cxx.o -o cmTC_99126
/usr/bin/ld: CMakeFiles/cmTC_99126.dir/src.cxx.o: in function main': src.cxx:(.text+0x48): undefined reference to pthread_create’
/usr/bin/ld: src.cxx:(.text+0x50): undefined reference to pthread_detach' /usr/bin/ld: src.cxx:(.text+0x5c): undefined reference to pthread_join’
collect2: error: ld returned 1 exit status
make[1]: *** [CMakeFiles/cmTC_99126.dir/build.make:87: cmTC_99126] Error 1
make[1]: Leaving directory ‘/home/nvidia/TensorRT/build/CMakeFiles/CMakeTmp’
make: *** [Makefile:121: cmTC_99126/fast] Error 2

Source file was:
include <pthread.h>

void* test_func(void* data)
{
return data;
}

int main(void)
{
pthread_t thread;
pthread_create(&thread, NULL, test_func, NULL);
pthread_detach(thread);
pthread_join(thread, NULL);
pthread_atfork(NULL, NULL, NULL);
pthread_exit(NULL);

return 0;
}

Determining if the function pthread_create exists in the pthreads failed with the following output:
Change Dir: /home/nvidia/TensorRT/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/make cmTC_e3bc8/fast && /usr/bin/make -f CMakeFiles/cmTC_e3bc8.dir/build.make CMakeFiles/cmTC_e3bc8.dir/build
make[1]: Entering directory ‘/home/nvidia/TensorRT/build/CMakeFiles/CMakeTmp’
Building CXX object CMakeFiles/cmTC_e3bc8.dir/CheckFunctionExists.cxx.o
/usr/bin/aarch64-linux-gnu-g++ -Wno-deprecated-declarations -DBUILD_SYSTEM=cmake_oss -DCHECK_FUNCTION_EXISTS=pthread_create -std=c++14 -o CMakeFiles/cmTC_e3bc8.dir/CheckFunctionExists.cxx.o -c /home/nvidia/TensorRT/build/CMakeFiles/CheckLibraryExists/CheckFunctionExists.cxx
Linking CXX executable cmTC_e3bc8
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_e3bc8.dir/link.txt --verbose=1
/usr/bin/aarch64-linux-gnu-g++ -Wno-deprecated-declarations -DBUILD_SYSTEM=cmake_oss -DCHECK_FUNCTION_EXISTS=pthread_create CMakeFiles/cmTC_e3bc8.dir/CheckFunctionExists.cxx.o -o cmTC_e3bc8 -lpthreads
/usr/bin/ld: cannot find -lpthreads
collect2: error: ld returned 1 exit status
make[1]: *** [CMakeFiles/cmTC_e3bc8.dir/build.make:87: cmTC_e3bc8] Error 1
make[1]: Leaving directory ‘/home/nvidia/TensorRT/build/CMakeFiles/CMakeTmp’
make: *** [Makefile:121: cmTC_e3bc8/fast] Error 2

How to solve the problem?

Answered by customer at Is there pre-built TensorRT Python package for DRIVE AGX Orin? - DRIVE AGX Orin / DRIVE AGX Orin General - NVIDIA Developer Forums