-
下载、解压到 ~/Software/nlopt-2.6.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 .. -
编译
make
make install -
配置库文件检索路径
gedit ~/.bashrc
在最后增加一行:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/Software/nlopt-2.6.2/build/lib
重新打开终端生效。 -
编译自己的程序
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
网友评论