

ubuntu系统编译安装PolyFit 1.4
source link: https://blog.whuzfb.cn/blog/2020/10/29/ubuntu_compile_polyfit/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

1. 下载Gurobi
注册账号,注意选择类型为学术,然后打开下载中心,选择Gurobi Optimizer点击,同意协议;然后选择最新版本9.0.2的linux压缩包进行下载并解压
2. 配置Gurobi
在Gurobi网站申请学术授权,然后即可看到自己的授权码
假设解压的目录为/home/zfb/gurobi902/linux64/
,运行命令:/home/zfb/gurobi902/linux64/bin/grbgetkey 116e332d-a688-77de-a234-1234aa30bdbe
如果授权成功会在/home/zfb/gurobi902/
目录下生成gurobi.lic
文件,此时可以通过在终端输入gurobi.sh
进入交互环境测试功能是否正常
为了方便使用,修改~/.bashrc
文件,添加以下内容:
export GUROBI_HOME=/home/zfb/gurobi902/linux64
export PATH=${PATH}:${GUROBI_HOME}/bin
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${GUROBI_HOME}/lib
export GRB_LICENSE_FILE=/home/zfb/gurobi.lic
然后source ~/.bashrc
使文件生效,最好登出再登录一次
3. 安装cgal与cmake
必须保证cmake
使用的boost
库的版本为1.65(如果为1.70会报错),所以如果原本已有boost1.70则需要手动卸载:
sudo apt-get --purge remove libboost-dev-all
sudo rm -rf /usr/local/lib/boost*
sudo rm -rf /usr/local/include/boost*
# 如果此前未使用过cmake,仅仅安装而已,否则不要执行这一步
sudo apt-get --purge remove cmake
# 删除cmake目录下的boost
sudo rm -rf /usr/local/lib/cmake/boost*
sudo rm -rf /usr/local/lib/cmake/Boost*
开始进行安装:
sudo apt-get install libcgal-dev
sudo apt-get install cmake
4. 安装Qt5
使用以下代码安装Qt5:
sudo apt-get install build-essential manpages-dev
sudo apt install make libqt5widgets5 libqt5gui5 libqt5dbus5 libqt5network5 libqt5core5a
sudo apt-get install qtcreator
sudo apt-get install qt5-default
然后即可运行qtcreator
或者点击图标打开项目或创建新项目
5. 下载Polyfit源代码
直接下载最新一次的commit代码,然后解压。假设解压到文件夹/home/zfb/Polyfit/
,修改/home/zfb/Polyfit/cmake/FindGUROBI.cmake
文件的如下部分:
# Hardcoded search paths
set(SEARCH_PATHS_FOR_HEADERS
"$ENV{GUROBI_HOME}/include"
"/Library/gurobi901/mac64/include"
"/home/zfb/gurobi902/linux64/include"
"C:\\dev\\gurobi901\\win64\\include"
)
set(SEARCH_PATHS_FOR_LIBRARIES
"$ENV{GUROBI_HOME}/lib"
"/Library/gurobi901/mac64/lib"
"/home/zfb/gurobi902/linux64/lib"
"C:\\dev\\gurobi901\\win64\\lib"
)
然后打开qtcreator
软件,选择打开项目,点击Polyfit文件夹下的CMakeLists.txt
文件,选择打开,然后点击配置项目,此时即可打开项目并自动执行cmake
,然后可以执行编译得到可执行文件,既可以选择生成debug版本,也可以选择release版本
如果遇到以下报错:
[100%] Linking CXX executable ../bin/PolyFit
../math/libmath.so: undefined reference to `GRBaddgenconstrAbs'
../math/libmath.so: undefined reference to `GRBaddgenconstrAnd'
../math/libmath.so: undefined reference to `GRBterminate'
../math/libmath.so: undefined reference to `GRBismodelfile'
../math/libmath.so: undefined reference to `GRBModel::addConstr(GRBTempConstr
....
collect2: error: ld returned 1 exit status
PolyFit/CMakeFiles/PolyFit.dir/build.make:305: recipe for target 'bin/PolyFit' failed
CMakeFiles/Makefile2:741: recipe for target 'PolyFit/CMakeFiles/PolyFit.dir/all' failed
Makefile:83: recipe for target 'all' failed
make[2]: *** [bin/PolyFit] Error 1
make[1]: *** [PolyFit/CMakeFiles/PolyFit.dir/all] Error 2
make: *** [all] Error 2
16:55:37: The process "/usr/bin/cmake" exited with code 2.
Error while building/deploying project PolyFit (kit: Desktop)
When executing step "CMake Build"
需要重新生成libgroubi_c++.a文件:
# 进入build文件夹并make生成库
cd gurobi902/linux64/src/build && make
# 移动备份原文件,防止直接覆盖
mv gurobi902/linux64/lib/libgroubi_c++.a ./
# 将生成的文件移动到lib目录
mv ./libgroubi_c++.a ../../lib/
然后再进行编译项目即可
晨曦
/
2020-10-29
/ 93 views
Published under(CC) BY-NC-SA 4.0.
Recommend
-
69
在Ubuntu下安装FFmpeg和x264
-
13
本教程/笔记,意在指导在Ubuntu及其他Linux系统上如何通过源码安装Octave。 Octave简介 Octave是GNU旗下代替matlab的数学工具软件,语法与matlab高度兼容,并且支持一些独有的更清晰更符合Linux社区习惯的语法。虽然在一些具体工具包和部分特...
-
18
Ubuntu 16.04 从 GitHub下载 caffe 源码,并且编译安装,Caffe 的依赖库都有什么作用? 发表于...
-
9
LWPC项目可以采用以下编译方法: 在linux系统编译和运行(需要安装cmake软件的linux版本,也可用apt安装) 在windows系统编译和运行(需要安装
-
4
Jager · 4月17日 · 2015年centos7 · linux · 操作系統 319次已读Redis的安...
-
10
OpenHarmony预置系统应用编译安装全流程记录 作者:拓维信息田怡婧 2022-02-21 14:49:26 SystemUI应用是OpenHarmony中预置的系统应用,为用户提供系统相关信息展示及交互界面,包括系统状态、系统提示、系...
-
4
ffmpeg在debian系统下编译安装 | K's Life Ho...
-
10
Detrend xarray DataArrays using polyfit · GitHub Instantly share code, notes, and snippets. Detrend xarray DataArrays usin...
-
7
Python 是一种特别优秀的编程语言,截止目前,tiobe 编程语言排行榜 上 Python 已长时间稳居第一。Python 语言使用者大多采用 Anaconda 或 Miniconda,但这些集成安装包采用的并不是最新的 Python...
-
6
FFmpeg支持Linux、macOS、Windows、Android等操作系统,其中Linux系列包括Ubuntu、Debian、Mint、CentOS、RHEL、Fedora等分支。FFmpeg官网的编译入口地址为
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK