Error while linking sampleOnnxMNIST tutorial

Description

I am trying to link one of the sample tutorials (sampleOnnxMNIST) using CMakeLists (attached).

Here is the linking error I get:

[100%] Linking CXX executable infer_LDC
/usr/bin/ld: CMakeFiles/infer_LDC.dir/main.cpp.o: in function `SampleOnnxMNIST::build()':
main.cpp:(.text+0xf35): undefined reference to `createInferBuilder_INTERNAL'
/usr/bin/ld: main.cpp:(.text+0xf91): undefined reference to `createNvOnnxParser_INTERNAL'
/usr/bin/ld: main.cpp:(.text+0x1154): undefined reference to `createInferRuntime_INTERNAL'
/usr/bin/ld: CMakeFiles/infer_LDC.dir/main.cpp.o: in function `createBuilder()':
main.cpp:(.text+0x11): undefined reference to `createInferBuilder_INTERNAL'
/usr/bin/ld: CMakeFiles/infer_LDC.dir/main.cpp.o: in function `createRuntime()':
main.cpp:(.text+0x31): undefined reference to `createInferRuntime_INTERNAL'
/usr/bin/ld: CMakeFiles/infer_LDC.dir/main.cpp.o: in function `createRefitter(nvinfer1::ICudaEngine&)':
main.cpp:(.text+0x51): undefined reference to `createInferRefitter_INTERNAL'
/usr/bin/ld: CMakeFiles/infer_LDC.dir/main.cpp.o: in function `createONNXParser(nvinfer1::INetworkDefinition&)':
main.cpp:(.text+0x71): undefined reference to `createNvOnnxParser_INTERNAL'
/usr/bin/ld: CMakeFiles/infer_LDC.dir/home/workpc/Downloads/software/TensorRT/TensorRT-8.6.1.6/samples/common/sampleOptions.cpp.o: in function `sample::(anonymous namespace)::removeSingleQuotationMarks(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)':
sampleOptions.cpp:(.text+0x6452): undefined reference to `sample::splitToStringVec(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char)'
/usr/bin/ld: CMakeFiles/infer_LDC.dir/home/workpc/Downloads/software/TensorRT/TensorRT-8.6.1.6/samples/common/sampleOptions.cpp.o: in function `std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > sample::(anonymous namespace)::splitNameAndValue<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
sampleOptions.cpp:(.text+0x65cd): undefined reference to `sample::splitToStringVec(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char)'
/usr/bin/ld: sampleOptions.cpp:(.text+0x6866): undefined reference to `sample::splitToStringVec(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char)'
/usr/bin/ld: CMakeFiles/infer_LDC.dir/home/workpc/Downloads/software/TensorRT/TensorRT-8.6.1.6/samples/common/sampleOptions.cpp.o: in function `std::vector<int, std::allocator<int> > sample::(anonymous namespace)::stringToValue<std::vector<int, std::allocator<int> > >(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
sampleOptions.cpp:(.text+0x8533): undefined reference to `sample::splitToStringVec(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char)'
/usr/bin/ld: CMakeFiles/infer_LDC.dir/home/workpc/Downloads/software/TensorRT/TensorRT-8.6.1.6/samples/common/sampleOptions.cpp.o: in function `std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<int, std::allocator<int> > > sample::(anonymous namespace)::splitNameAndValue<std::vector<int, std::allocator<int> > >(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
sampleOptions.cpp:(.text+0x8739): undefined reference to `sample::splitToStringVec(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char)'
/usr/bin/ld: CMakeFiles/infer_LDC.dir/home/workpc/Downloads/software/TensorRT/TensorRT-8.6.1.6/samples/common/sampleOptions.cpp.o:sampleOptions.cpp:(.text+0x89a6): more undefined references to `sample::splitToStringVec(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char)' follow
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/infer_LDC.dir/build.make:196: infer_LDC] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/infer_LDC.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

This example builds file if I navigate to
TensorRT-8.6.1.6/samples/sampleOnnxMNIST/
and type make.

Any ideas please?

Environment

TensorRT Version: TensorRT-8.6.1.6
GPU Type: RTX 2060
Nvidia Driver Version: 535
CUDA Version: 12.2
CUDNN Version:
Operating System + Version: Ubuntu 22.04
Python Version (if applicable):
TensorFlow Version (if applicable):
PyTorch Version (if applicable):
Baremetal or Container (if container which image + tag):
CMakeLists.txt (1.8 KB)

Hi,

Could you please upgrade to the latest Cmake version and try again?
If you continue to have problems, please visit Issues · NVIDIA/TensorRT · GitHub for better help on compilation errors.

Thank you.