0


CMake Error at CMakeLists.txt: (FIND_PACKAGE)找不到ncnn包的解决方法

问题描述

demo指路:https://github.com/EdVince/Stable-Diffusion-NCNN
Linux端使用

cmake

编译文件时,

cd x86/linux
mkdir-p build &&cd build
cmake ..make -j$(nproc)

执行

cmake ..

命令,报错:

CMake Error at CMakeLists.txt:14 (FIND_PACKAGE):
  By not providing "Findncnn.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "ncnn", but
  CMake did not find one.

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

    ncnnConfig.cmake
    ncnn-config.cmake

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

-- Configuring incomplete, errors occurred!
See also "/home/gaoyi/ldm-ncnn/Stable-Diffusion-NCNN/x86/linux/CMakeFiles/CMakeOutput.log".

问题原因

拉取

ncnn

的代码库(包括submodule)后没有

build and Install

,所以

cmake

时找不到对应的包,只需要让它找到对应的包即可,分为2步:

  1. 生成对应的cmake文件(ncnnConfig.cmakencnn-config.cmake
  2. 设置环境变量(CMAKE_PREFIX_PATH或者ncnn_DIR

解决方法

  1. build and Install ncnn

需要执行以下命令:

cd ncnn
mkdir-p build
cd build
cmake ..
cmake

之后继续在build目录下,执行:

makeinstall

发现弹出的信息中有:

这其中的

ncnnConfig.cmake、ncnn.cmake

就是我们需要找的包,找到上一级目录,右键复制路径

  1. 设置环境变量
exportncnn_DIR=/home/gaoyi/ldm-ncnn/Stable-Diffusion-NCNN/ncnn/build/install/lib/cmake/ncnn

这个环境变量就是上一步复制的路径

  1. 重新运行cmake
cmake ..

看到:

-- Configuring done
-- Generating done
-- Build files have been written to: /home/gaoyi/ldm-ncnn/Stable-Diffusion-NCNN/x86/linux

成功!

标签: linux

本文转载自: https://blog.csdn.net/qq_45510888/article/details/129248757
版权归原作者 masteryi-0018 所有, 如有侵权,请联系我们删除。

“CMake Error at CMakeLists.txt: (FIND_PACKAGE)找不到ncnn包的解决方法”的评论:

还没有评论