CMake 3.13 Error Installation of a program

Hi everybody,

I have a question for a CMake related issue with installing a program.
I use this command to install TensorRT with CMake:
cmake .. -DTENSORRT_ROOT=/usr/src/tensorrt/samples/python/yolov3_onnx/onnx-tensorrt/-DGPU_ARCHS="72"

If I try this, I get this error message:

-- The CXX compiler identification is GNU 7.4.0
-- The C compiler identification is GNU 7.4.0
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
CMake Error at /usr/local/share/cmake-3.13/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
  Could NOT find Protobuf (missing: Protobuf_INCLUDE_DIR)
Call Stack (most recent call first):
  /usr/local/share/cmake-3.13/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
  /usr/local/share/cmake-3.13/Modules/FindProtobuf.cmake:595 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:89 (FIND_PACKAGE)


-- Configuring incomplete, errors occurred!
See also "/usr/src/tensorrt/samples/python/yolov3_onnx/onnx-tensorrt/onnx_tensorrt/CMakeFiles/CMakeOutput.log".
See also "/usr/src/tensorrt/samples/python/yolov3_onnx/onnx-tensorrt/onnx_tensorrt/CMakeFiles/CMakeError.log".

I checked the error log, which says this:

Determining if the pthread_create exist failed with the following output:
Change Dir: /usr/src/tensorrt/samples/python/yolov3_onnx/onnx-tensorrt/onnx_tensorrt/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTC_798cc/fast"
/usr/bin/make -f CMakeFiles/cmTC_798cc.dir/build.make CMakeFiles/cmTC_798cc.dir/build
make[1]: Entering directory '/usr/src/tensorrt/samples/python/yolov3_onnx/onnx-tensorrt/onnx_tensorrt/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_798cc.dir/CheckSymbolExists.c.o
/usr/bin/cc   -fPIE   -o CMakeFiles/cmTC_798cc.dir/CheckSymbolExists.c.o   -c /usr/src/tensorrt/samples/python/yolov3_onnx/onnx-tensorrt/onnx_tensorrt/CMakeFiles/CMakeTmp/CheckSymbolExists.c
Linking C executable cmTC_798cc
/usr/local/bin/cmake -E cmake_link_script CMakeFiles/cmTC_798cc.dir/link.txt --verbose=1
/usr/bin/cc      CMakeFiles/cmTC_798cc.dir/CheckSymbolExists.c.o  -o cmTC_798cc 
CMakeFiles/cmTC_798cc.dir/CheckSymbolExists.c.o: In function `main':
CheckSymbolExists.c:(.text+0x14): undefined reference to `pthread_create'
CheckSymbolExists.c:(.text+0x18): undefined reference to `pthread_create'
collect2: error: ld returned 1 exit status
CMakeFiles/cmTC_798cc.dir/build.make:86: recipe for target 'cmTC_798cc' failed
make[1]: *** [cmTC_798cc] Error 1
make[1]: Leaving directory '/usr/src/tensorrt/samples/python/yolov3_onnx/onnx-tensorrt/onnx_tensorrt/CMakeFiles/CMakeTmp'
Makefile:121: recipe for target 'cmTC_798cc/fast' failed
make: *** [cmTC_798cc/fast] Error 2

File /usr/src/tensorrt/samples/python/yolov3_onnx/onnx-tensorrt/onnx_tensorrt/CMakeFiles/CMakeTmp/CheckSymbolExists.c:
/* */
#include <pthread.h>

int main(int argc, char** argv)
{
  (void)argv;
#ifndef pthread_create
  return ((int*)(&pthread_create))[argc];
#else
  (void)argc;
  return 0;
#endif
}

Determining if the function pthread_create exists in the pthreads failed with the following output:
Change Dir: /usr/src/tensorrt/samples/python/yolov3_onnx/onnx-tensorrt/onnx_tensorrt/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTC_da39a/fast"
/usr/bin/make -f CMakeFiles/cmTC_da39a.dir/build.make CMakeFiles/cmTC_da39a.dir/build
make[1]: Entering directory '/usr/src/tensorrt/samples/python/yolov3_onnx/onnx-tensorrt/onnx_tensorrt/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_da39a.dir/CheckFunctionExists.c.o
/usr/bin/cc   -DCHECK_FUNCTION_EXISTS=pthread_create -fPIE   -o CMakeFiles/cmTC_da39a.dir/CheckFunctionExists.c.o   -c /usr/local/share/cmake-3.13/Modules/CheckFunctionExists.c
Linking C executable cmTC_da39a
/usr/local/bin/cmake -E cmake_link_script CMakeFiles/cmTC_da39a.dir/link.txt --verbose=1
/usr/bin/cc  -DCHECK_FUNCTION_EXISTS=pthread_create    CMakeFiles/cmTC_da39a.dir/CheckFunctionExists.c.o  -o cmTC_da39a -lpthreads 
/usr/bin/ld: cannot find -lpthreads
collect2: error: ld returned 1 exit status
CMakeFiles/cmTC_da39a.dir/build.make:86: recipe for target 'cmTC_da39a' failed
make[1]: *** [cmTC_da39a] Error 1
make[1]: Leaving directory '/usr/src/tensorrt/samples/python/yolov3_onnx/onnx-tensorrt/onnx_tensorrt/CMakeFiles/CMakeTmp'
Makefile:121: recipe for target 'cmTC_da39a/fast' failed
make: *** [cmTC_da39a/fast] Error 2

Because I have no real clue, what the errors could mean, I will describe my ideas about it:
As far as I understand, the upper error says that protobuf could not be found. So maybe it would be a way to include the protobuf path to my CMakeLists.txt? If yes, how could I do this?
In the lower error I think I would need to include a reference to ‘pthread_create’?
Does anyone has an idea how both of the errors are connected?
Further information is, that I am working on a Nvidia Jetson AGX Xavier (ARM architecture) on Ubuntu 18.04. CMake Version 3.10 was installed, but I needed at least 3.13 for an installation. So I installed a new version via this way:

cd /opt
sudo chmod +x cmake-3.13.4.tar.gz 
sudo tar -xvf cmake-3.13.4.tar.gz
cd cmake-3.13.4/
sudo ./configure
sudo make install

Could it be possible, that there happened some mistakes while doing the configuration, that some variables are missing?

Does anyone has an idea what I am doing wrong or any suggestion what I could change?

This says that you don’t have Protobuf headers installed. You’ll need the libprotobuf-dev package (or equivalent for your distro) to build. The pthread_create errors are unrelated to the real error here (something is trying to see if the symbol exists: and it doesn’t, not without additional flags).