2021-05-22 NLopt的安装

  • 原始文档 https://nlopt.readthedocs.io/en/latest/NLopt_Installation/

  • 安装步骤

  1. 下载、解压到 ~/Software/nlopt-2.6.2

  2. 创建编译目录
    mkdir ~/Software/nlopt-2.6.2/build
    cd ~/Software/nlopt-2.6.2/build
    cmake -DCMAKE_INSTALL_PREFIX=/home/c2019/Software/nlopt-2.6.2/build ..

  3. 编译
    make
    make install

  4. 配置库文件检索路径
    gedit ~/.bashrc
    在最后增加一行:
    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/Software/nlopt-2.6.2/build/lib
    重新打开终端生效。

  5. 编译自己的程序
    cd ~/Software/nlopt-2.6.2/test
    c++ -I/home/c2019/Software/nlopt-2.6.2/build/include/ t_tutorial.cxx -L/home/c2019/Software/nlopt-2.6.2/build/lib/ -lnlopt -lm -o t_tutorial
    输出
    found minimum at f(0.333333,0.296296) = 0.5443310474

你可能感兴趣的:(2021-05-22 NLopt的安装)