Hi,there is a similar problem …
When libtorch is built with opencv :
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
project(simnet)

find_package(Torch REQUIRED)
find_package(OpenCV 4 REQUIRED)

message(STATUS "Pytorch status:")
message(STATUS "    libraries: ${TORCH_LIBRARIES}")

message(STATUS "OpenCV library status:")
message(STATUS "    version: ${OpenCV_VERSION}")
message(STATUS "    libraries: ${OpenCV_LIBS}")
message(STATUS "    include path: ${OpenCV_INCLUDE_DIRS}")

add_executable(simnet main.cpp)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)

target_link_libraries(simnet "${TORCH_LIBRARIES}")
target_link_libraries(simnet "${OpenCV_LIBS}")

It will give rise to ‘undefined reference to `cv::imread(std::string const&, int)’’
And when I removed ‘target_link_libraries(simnet “${TORCH_LIBRARIES}”)’ and the build process succeeded.