Ubuntu18.04安装nlopt

Ubuntu18.04安装nlopt

文章目录

  • Ubuntu18.04安装nlopt
    • 1. nlopt官网下载压缩包
    • 2. 解压
    • 3. 编译nlopt文件
    • 4. 参考

1. nlopt官网下载压缩包

nlopt官网地址

Ubuntu18.04安装nlopt_第1张图片

2. 解压

进入到解压后的文件夹,执行下面命令:

cmake . && make && sudo make install

Ubuntu18.04安装nlopt_第2张图片

3. 编译nlopt文件

编译后会报错, Could not find “FindNLOPT.cmake”

By not providing "FindNLOPT.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "NLOPT", but
  CMake did not find one.
  
  Could not find a package configuration file provided by "NLOPT" with any of
  the following names:
    NLOPTConfig.cmake
    nlopt-config.cmake
    
  Add the installation prefix of "NLOPT" to CMAKE_PREFIX_PATH or set
  "NLOPT_DIR" to a directory containing one of the above files.  If "NLOPT"
  provides a separate development package or SDK, be sure it has been
  installed.

Ubuntu18.04安装nlopt_第3张图片

在CMakelist.txt中添加xxx.cmake所在的路径到查找路径。
解决以上报错的两种方法:

  1. 添加 set (NLOPT_DIR "/home/qiancj/nlopt/")

在这里插入图片描述

  1. 添加 set (CMAKE_PREFIX_PATH "pathtoxxx.cmake")

  2. 添加 list(APPEND CMAKE_FIND_ROOT_PATH "pathtoxxx.cmake")

4. 参考

Cmake编译错误–怕忘,遇到些特殊的问题记下来-TODO

你可能感兴趣的:(Linux,linux)