When i import my python module which implements a image process unit using c++ Opencv and Pybind11, i got this error. I have tried the version of 4.0.0/4.1.0/4.1.2/4.2.0/4.3.0/4.4.0 and got the same result. However, when i update the version to 4.5, the error gone. I want to fix this problem since version 4.5 has harm my code performance. Any suggestions would be grateful! My CMakeLists.txt is shown below:
project(dbpost_module LANGUAGES CXX)
cmake_minimum_required(VERSION 3.12)
find_package(pybind11 REQUIRED)
find_package(OpenCV REQUIRED)
find_package(Torch 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}")
include_directories(${PYTHON_INCLUDE_DIRS} ${_numpy_include_dirs} ${OpenCV_INCLUDE_DIRS})
include_directories("/usr/local/lib/")
message("Python libs: ${PYTHON_LIBRARIES}")
find_library(TORCH_PYTHON_LIBRARY torch_python PATHS "${TORCH_INSTALL_PREFIX}/lib")
message(STATUS "TORCH_PYTHON_LIBRARY: ${TORCH_PYTHON_LIBRARY}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}")
pybind11_add_module(dbpost_module dbpost_module.cpp)
target_link_libraries(dbpost_module PUBLIC ${OpenCV_LIBS} PUBLIC ${TORCH_LIBRARIES} PUBLIC ${TORCH_PYTHON_LIBRARY})
set_property(TARGET dbpost_module PROPERTY CXX_STANDARD 14)
Result:
>>> import torch
>>> import dbpost_module
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: /home/***/inference/new_ocr/svrep_git/models/post_processing/db_post_cpp/build/dbpost_module.cpython-36m-x86_64-linux-gnu.so: undefined symbol: _ZN2cv5errorEiRKSsPKcS3_i