linux下基于官方源码编译ipopt

linux,ipopt · 浏览次数 : 0

小编点评

**Ipopt1、C++依赖项安装升级** **准备** 1. 安装依赖项:`apt-get updateapt-get -y upgradeapt install build-essentialapt-get install -y gcc g++ gfortran git patch wget pkg-config liblapack-dev libmetis-dev libblas-dev vim2` 2. 下载需要编译的代码文件总共有5个重要的文件包: ``` 1. Ipopt 2. ThirdParty-ASL 3. ThirdParty-HSL 4. ThirdParty-Mumps 5. coinhsl.zip ``` **构建Ipopt1** 1. 下载coinhsl.zip文件 2. 解压缩coinhsl.zip到ThirdParty-HSLcp目录 3. 配置环境变量:`cd /usr/local/include && echo "Add the/usr/local/lib directory to the configuration file of the shared library" >> /etc/ld.so.conf` 4. 执行构建命令:`./configuremakemake install` **构建ThirdParty-ASL和ThirdParty-HSL** 1. 下载ThirdParty-ASL和ThirdParty-HSL代码 2. 解压缩ThirdParty-ASL和ThirdParty-HSL代码 3. 配置环境变量:`cd ThirdParty-HSL && echo "Add the/ThirdParty-HSL/coinhsl.zip to the configuration file of the shared library" >> /etc/ld.so.conf` 4. 解压缩coinhsl.zip 5. 执行构建命令:`./configuremakemake install` **构建ThirdParty-Mumps** 1. 下载ThirdParty-Mumps代码 2. 解压缩ThirdParty-Mumps代码 3. 配置环境变量:`cd ThirdParty-Mumps && echo "Add the/ThirdParty-Mumps to the configuration file of the shared library" >> /etc/ld.so.conf` 4. 执行构建命令:`./configuremakemake install` **构建Ipoptcd** 1. 下载Ipopt代码 2. 解压缩Ipopt代码 3. 配置环境变量:`cd Ipopt && echo "Add the/usr/local/lib directory to the configuration file of the shared library" >> /etc/ld.so.conf` 4. 执行构建命令:`./configuremakemake testmake install`

正文

linux下基于官方源码编译ipopt

1、C++依赖项安装升级

由于需要编译c++所以需要安装一系列的依赖:

apt-get update
apt-get -y upgrade
apt install build-essential
apt-get install -y gcc g++ gfortran git patch wget pkg-config liblapack-dev libmetis-dev libblas-dev vim

2、下载需要编译的代码文件

总共有5个重要的文件包:

1. Ipopt :https://github.com/coin-or/Ipopt.git
2. ThirdParty-ASL : https://github.com/coin-or-tools/ThirdParty-ASL.git
3. ThirdParty-HSL : https://github.com/coin-or-tools/ThirdParty-HSL.git
4. ThirdParty-Mumps : https://github.com/coin-or-tools/ThirdParty-Mumps.git
5. coinhsl.zip : 为ThirdParty-HSL编译的依赖项,其官网为: [Coin-HSL available from STFC IP Store](https://licences.stfc.ac.uk/product/coin-hsl) ,该文件下载比较麻烦且很难查找的到

3、编译文件

  1. 编译ThirdParty-ASL

    cd ThirdParty-ASL || exit
    ./get.ASL
    ./configure
    make
    make install
    
  2. 编译ThirdParty-HSL

    1. 将coinhsl.zip解压到ThirdParty-HSL

      cp coinhsl.zip ThirdParty-HSL
      cd ThirdParty-HSL || exit
      unzip coinhsl.zip
      
    2. 编译

      ./configure
      make
      make install
      
  3. 编译ThirdParty-Mumps

    cd ThirdParty-Mumps || exit
    ./get.Mumps
    ./configure
    make
    make install
    
  4. 编译Ipopt

    cd Ipopt || exit
    mkdir build
    cd build || exit
    ../configure
    make
    make test
    make install
    

4、配置环境变量

cd /usr/local/include || exit
cp coin-or coin -r
ln -s /usr/local/lib/libcoinmumps.so.3 /usr/lib/libcoinmumps.so.3
ln -s /usr/local/lib/libcoinhsl.so.2 /usr/lib/libcoinhsl.so.2
ln -s /usr/local/lib/libipopt.so.3 /usr/lib/libipopt.so.3
echo "Add the/usr/local/lib directory to the configuration file of the shared library"
echo "/usr/local/lib" >> /etc/ld.so.conf
ldconfig

5、一键式操作脚本

  1. 预先下载文件:夸克链接:https://pan.quark.cn/s/8928a21eaf0b
  2. 在文件夹Ipopt_pkg下,存放提供的两个压缩文件:coinhsl.zip ; Ipopt_pkg.zip
  3. 在Ipopt_pkg文件夹的同级地址下执行脚本depoly_ipopt.sh

文件结构树:

-- Ipopt_pkg
	- coinhsl.zip
	- Ipopt_pkg.zip
-- depoly_ipopt.sh

depoly_ipopt.sh :

#!/bin/bash
echo "Compile ipopt and dependencies:" # echo is used to printf in terminal
echo "dependencies: gcc g++ gfortran git patch wget pkg-config liblapack-dev libmetis-dev libblas-dev"
apt-get update
apt-get -y upgrade
apt install build-essential
apt-get install -y gcc g++ gfortran git patch wget pkg-config liblapack-dev libmetis-dev libblas-dev vim
echo "===========================dependencies: over====================================="
if [ ! -d "/Ipopt_pkg" ]; then
  mkdir /Ipopt_pkg
fi
cd Ipopt_pkg || exit
unzip Ipopt_pkg.zip
echo "===========================make ASL==========================="
if [ ! -d "/ThirdParty-ASL" ]; then
  git clone https://github.com/coin-or-tools/ThirdParty-ASL.git
fi
cd ThirdParty-ASL || exit
./get.ASL
./configure
make
make install
cd ..
echo "===========================make HSL==========================="
if [ ! -d "/ThirdParty-HSL" ]; then
  git clone https://github.com/coin-or-tools/ThirdParty-HSL.git
fi

if [ ! -d "/ThirdParty-HSL/coinhsl.zip" ]; then
  cp coinhsl.zip ThirdParty-HSL  # 将预先下载好的线性求解器编译文件压缩包添加到文件夹ThirdParty-HSL内
fi

cd ThirdParty-HSL || exit
unzip coinhsl.zip
./configure
make
make install
cd ..
echo "===========================make Mumps==========================="
if [ ! -d "/ThirdParty-Mumps" ]; then
  git clone https://github.com/coin-or-tools/ThirdParty-Mumps.git
fi
cd ThirdParty-Mumps || exit
./get.Mumps
./configure
make
make install
cd ..
echo "===========================make Ipopt==========================="
if [ ! -d "/Ipopt" ]; then
  git clone https://github.com/coin-or/Ipopt.git
fi
cd Ipopt || exit
mkdir build
cd build || exit
../configure
make
make test
make install
echo "===========================Improve the environment==========================="
cd /usr/local/include || exit
cp coin-or coin -r
ln -s /usr/local/lib/libcoinmumps.so.3 /usr/lib/libcoinmumps.so.3
ln -s /usr/local/lib/libcoinhsl.so.2 /usr/lib/libcoinhsl.so.2
ln -s /usr/local/lib/libipopt.so.3 /usr/lib/libipopt.so.3
echo "Add the/usr/local/lib directory to the configuration file of the shared library"
echo "/usr/local/lib" >> /etc/ld.so.conf
ldconfig
echo "===========================Compile ipopt and dependencies: over!==========================="

与linux下基于官方源码编译ipopt相似的内容:

linux下基于官方源码编译ipopt

linux下基于官方源码编译ipopt 1、C++依赖项安装升级 由于需要编译c++所以需要安装一系列的依赖: apt-get update apt-get -y upgrade apt install build-essential apt-get install -y gcc g++ gfort

Linux下JDK的安装配置

一、官网下载JDK1.8 https://www.oracle.com/java/technologies/oracle-java-archive-downloads.html JDK1.8 因为1.8是目前项目中用到最多的 基本都是基于JDK1.8 可以直接在虚拟机中的浏览器访问下载,但是尝试过的

[转帖]linux命令行下如何格式化json并进行各种json处理操作

https://blog.csdn.net/penriver/article/details/122016563 有时需要在linux 的命令行下,需要查看json的内容或针对json进行各种操作,本文针对此进行梳理、总结。 在Linux系统下基于python json.tool可以格式化json,

.NET周报【1月第1期 2023-01-06】

国内文章 【开源】基于.net6+gtksharp实现的Linux下的图形界面串口调试工具 https://www.cnblogs.com/flykai/p/17007554.html 由于公司的上位机等硬件项目都是基于Linux操作系统的,软硬件通讯调试麻烦,市面上又没有好用的图形操作软件来实现便

[转帖]linux下性能测试工具netperf使用

https://www.shuzhiduo.com/A/MyJxX2VpJn/ 一、功能简介 netperf是一款针对网络性能的测试工具,主要基于TCP或UDP的传输。根据应用的不同,可以进行批量数据传输(bulk data transfer)模式和请求/应答(request/reponse)模式的

DHorse v1.3.2 发布,基于 k8s 的发布平台

## 版本说明 ### 新增特性 * 构建版本、部署应用时的线程池可配置化; ### 优化特性 * 构建版本跳过单元测试; ### 解决问题 * 解决Vue应用详情页面报错的问题; * 解决Linux环境下脚本运行失败的问题; * 解决下载Maven安装文件失败的问题; ### 升级说明 下载v1.

JumpServer(v2.28.6) 堡垒机添加Linux资产 (图文教程)

前面介绍了如何在《CentOS7下搭建JumpServer 堡垒机》,基于这篇文章的环境搭建过程,接着介绍安装后的的功能配置使用。 首次wbe登录,https://ip:80,默认账号密码:admin,admin;这里自定义密码修改:admin@123 用户管理项 创建系统角色 创建用户 创建用户组

Debian Linux 的安装

Debian Linux 的安装 作者:Grey 原文地址: 博客园:Debian Linux 的安装 CSDN:Debian Linux 的安装 说明 本安装说明是基于 Windows 10 下 VMware workstation 16 安装 Linux,Linux 版本是 Debian 11,

Linux 中的文件简单说明

Linux 中的文件简单说明 作者:Grey 原文地址: 博客园:Linux 中的文件简单说明 CSDN:Linux 中的文件简单说明 说明 本文基于 CentOS 7 根目录(/)下文件夹主要作用 [root@linux /]# ll / total 16 lrwxrwxrwx. 1 root r

CentOS Linux 的安装

CentOS Linux 的安装 作者:Grey 原文地址: 博客园:CentOS Linux 的安装 CSDN:CentOS Linux 的安装 说明 本安装说明是基于 Windows 10 下 VMware workstation 16 安装 Linux,Linux 版本是 CentOS 8,需