pytorch LibTorch和OpenCV库在同一个cmakelist文件中不工作

muk1a3rh  于 2023-08-05  发布在  其他
关注(0)|答案(2)|浏览(106)
cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
project(Detect)
#set(Torch "/home/somnath/libtorch/share/cmake/Torch")
find_package(Torch REQUIRED)
find_package(OpenCV REQUIRED)
message(STATUS "CVINCLUDE: ${OpenCV_INCLUDE_DIRS}")
include_directories(${OpenCV_INCLUDE_DIRS})
add_executable(Detect main.cpp)
target_link_libraries(Detect  ${TORCH_LIBRARIES}; ${OpenCV_LIBS})

字符串
${token_token};如果要使用${OpenCV_LIBS}构建代码,则两者不会同时工作。
enter image description here

iibxawm4

iibxawm41#

尝试将libTorch从Pre-cxx 11 ABI更改为cxx 11 ABI
https://pytorch.org/get-started/locally/
感谢来自https://stackoverflow.com/a/61459156/13045595的Jacob HM

yeotifhr

yeotifhr2#

我也曾面临同样的问题。花了20多个小时来改变CMake文件和其他东西...但与CMakeLists.txt无关..如果你的代码中有“使用命名空间cv”,只需注解...它对我有效。希望它能解决你的问题。

  • 谢谢-谢谢

相关问题