2
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})

${TORCH_LIBRARIES}; ${OpenCV_LIBS} both are not working at the same time if want to use to build the code.

enter image description here

5
  • 1
    Please, elaborate "not working": what is happened, what error do you get, etc. Commented Sep 7, 2021 at 12:56
  • attached screenshot is the error for not able link library of opencv Commented Sep 7, 2021 at 14:29
  • 2
    No, do not use screenshots for error messages and code: meta.stackoverflow.com/questions/285551/…. Instead, copy paste the error message into the question post as text. See also How to Ask. Commented Sep 7, 2021 at 17:11
  • Hi @Pixolish did you solve the issue, Commented Sep 27, 2021 at 8:33
  • Does this answer your question? CMake linking error, finding library but "undefined reference" Commented Jun 12, 2022 at 11:45

2 Answers 2

1

Try to change the libTorch from Pre-cxx11 ABI to cxx11 ABI

https://pytorch.org/get-started/locally/

All thanks to Jacob HM from https://stackoverflow.com/a/61459156/13045595

Sign up to request clarification or add additional context in comments.

Comments

-1

I had face the same problem. Spent 20+hrs to change CMake file and what not...But there is nothing to do with CMakeLIsts.txt ..Just comment "using namespace cv" if you have in your code...It worked for me. Hope it solves your problem.

Thanks.

1 Comment

If you look at the error you see they are using the fully qualified name (cv::foo), so using namespace cv wouldn't help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.