asked CMake to find a package configuration file provided by “onnxruntime“, but CMake did not find

记一次部署onnxruntime库的小众bug

将onnxruntime库和cuda版本匹配好后,我将其安装在/usr/local/目录下,同时在项目的CMakeLists.txt文件下指定find_package(onnxruntime REQUIRED),然后进行编译操作,发现find_package无法找到相应的库,报错如下:

CMake Error at quadruped/CMakeLists.txt:40 (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.

随后我将find_package改为如下代码:

set(onnxruntime_DIR "/usr/local/onnxruntime")
set(onnxruntime_INCLUDE_DIRS "${onnxruntime_DIR}/include")
set(onnxruntime_LIBRARIES "${onnxruntime_DIR}/lib")
include_directories(${onnxruntime_INCLUDE_DIRS})
link_directories(${onnxruntime_LIBRARIES})

虽然cmake不报错了,但编译到最后进行链接的时候还是报了个错,如下所示:

undefined reference to `OrtGetApiBase' collect2: error: ld returned 1 exit status

查了半天,最终发现是lib库要指定到文件,不能仅仅是路径,遂将onnxruntime_LINBRARIES改为:

set(onnxruntime_LIBRARIES "${onnxruntime_DIR}/lib/libonnxruntime.so")

之后编译通过。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值