chineseocr_lite icon indicating copy to clipboard operation
chineseocr_lite copied to clipboard

onnx的cpp工程,cmake找不到OnnxRuntime

Open MistEO opened this issue 3 years ago • 1 comments

这个教程来的

报错

-- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.19043.
OPENMP FOUND
CMake Error at CMakeLists.txt:55 (find_package):
  By not providing "FindOnnxRuntime.cmake" in CMAKE_MODULE_PATH this project
  has asked CMake to find a package configuration file provided by
  "OnnxRuntime", but CMake did not find one.

  Could not find a package configuration file provided by "OnnxRuntime" with
  any of the following names:

    OnnxRuntimeConfig.cmake
    onnxruntime-config.cmake

  Add the installation prefix of "OnnxRuntime" to CMAKE_PREFIX_PATH or set
  "OnnxRuntime_DIR" to a directory containing one of the above files.  If
  "OnnxRuntime" provides a separate development package or SDK, be sure it
  has been installed.

确定目录是对的,因为我手动修改CMakeLists.txt,把第49~54行

# OnnxRuntime
if (OCR_STATIC)
    set(OnnxRuntime_DIR "${CMAKE_CURRENT_SOURCE_DIR}/onnxruntime-static")
else ()
    set(OnnxRuntime_DIR "${CMAKE_CURRENT_SOURCE_DIR}/onnxruntime-shared")
endif ()

改成

# OnnxRuntime
if (OCR_STATIC)
    set(OnnxRuntime_DIR "${CMAKE_CURRENT_SOURCE_DIR}/onnxruntime-static/windows-x64")
else ()
    set(OnnxRuntime_DIR "${CMAKE_CURRENT_SOURCE_DIR}/onnxruntime-shared/windows-x64")
endif ()

就可以正常cmake了

MistEO avatar Aug 07 '21 19:08 MistEO

按上面说的,手动改完了还是不行,cmake能过但是编译报错,onnxruntime的include也不对

换了onnx-1.6的那个压缩包就可以了;看了下应该是onnx-1.7压缩包里目录结构不太对

MistEO avatar Aug 07 '21 20:08 MistEO