[Solved] 1.fatal error: NvInfer.h: No such file or directory

yolov5 compile to generate engine error: /tensorrtx/yolov5/yololayer.h:6:10: fatal error: NvInfer.h: No such file or directory 6 | #include <NvInfer.h>
|          ^~~~~~~~~~~
compilation terminated.

1. The header file and library corresponding to tensorRT were not found.

In CMakeLists.txt
#tensorrt Add tensorrt corresponding header files and link libraries
# tensorrt
#include_directories(/usr/include/x86_64-linux-gnu/)
#link_directories(/usr/lib/x86_64-linux-gnu/)

include_directories(/home/******/TensorRT-7.2.3.4/include)
link_directories(/home/******/TensorRT-7.2.3.4/lib/)

Read More: