Ubuntu 16.04编译Octave-7.1.0
Ubuntu16.04可以通过apt安装Octave4.2.2,但是我的电脑上使用这个版本的Octave画图Figure经常显示不出来曲线,所以就萌生了自己编译Octave的想法,编译Octave可以参考Octave官网Wiki。
Ubuntu 16.04可以通过apt安装Octave 4.2.2,但是我的电脑上使用这个版本的Octave画图Figure经常显示不出来曲线,所以就萌生了自己编译Octave的想法,编译Octave可以参考Octave官网的编译Wiki。
安装依赖
参考Ubuntu Building Step,Ubuntu 16.04依赖懒人安装方法为:
sudo apt-get install gcc g++ gfortran make libopenblas-dev liblapack-dev libpcre3-dev libarpack2-dev libcurl4-gnutls-dev epstool libfftw3-dev transfig libfltk1.3-dev libfontconfig1-dev libfreetype6-dev libgl2ps-dev libglpk-dev libreadline-dev gnuplot-x11 libgraphicsmagick++1-dev libhdf5-serial-dev openjdk-8-jdk libsndfile1-dev llvm-dev lpr texinfo libgl1-mesa-dev libosmesa6-dev pstoedit portaudio19-dev libqhull-dev libqrupdate-dev libqscintilla2-dev libqt4-dev libqtcore4 libqtwebkit4 libqt4-network libqtgui4 libqt4-opengl-dev libsuitesparse-dev texlive libxft-dev zlib1g-dev autoconf automake bison flex gperf gzip icoutils librsvg2-bin libtool perl rsync tar
如果依赖安装有冲突问题,建议使用aptitude解决。
要想编译带GUI界面的Octave,还得安装QT,可以参考QT5安装。这里有个坑就是,安装好QT之后"安装目录/5.15.2/gcc_64/lib/pkgconfig"里面的.pc文件prefix不一定对,需要修改所有的.pc文件。我用jedit进行了批量替换,把"prefix=/home/qt/work/install"换成了"prefix=/opt/qt5.15.x/5.15.2/gcc_64"。为了让configure能找到安装好的QT,还要把QT pkgconfig文件夹加入到PKG_CONFIG_PATH中,参考QT PKG_CONFIG_PATH:
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/opt/qt5.15.x/5.15.2/gcc_64/lib/pkgconfig/
下载源码
wget https://ftpmirror.gnu.org/octave/octave-7.1.0.tar.gz && \
tar -xzf octave-7.1.0.tar.gz && \
cd octave-7.1.0
Configure & Build
先生成makeinstall文件:
mkdir .build && \
cd .build && \
./../configure --prefix=$HOME/my_octave && \ [1]
“$HOME/my_octave"中"my_octave"可以改成自己想要的名字。我改成了"shiliu_octave”,记住这个路径,下面会用到。
然后编译:
make -j4
QT flags报错
报错:
uic: Unknown option 'qt'.
修改.build文件下面的Makefile,把uic后面的qt5 flag删掉,将
UICFLAGS = -qt=5
改为
UICFLAGS =
报错:
rcc: Unknown option 'qt'.
类似地,将
RCCFLAGS = -qt=5
改成
RCCFLAGS =
如果moc也报错的话,就进行类似的修改,这里参考了Unknown option 'qt5’的解决思路。
QT语言转换文件报错
报错:
GEN libgui/languages/be_BY.qm
Usage:
lrelease [options] -project project-file
lrelease [options] ts-files [-qm qm-file]
lrelease is part of Qt's Linguist tool chain. It can be used as a
stand-alone tool to convert XML-based translations files in the TS
format into the 'compiled' QM format used by QTranslator objects.
Passing .pro files to lrelease is deprecated.
Please use the lrelease-pro tool instead, or use qmake's lrelease.prf
feature.
Options:
-help Display this information and exit
-idbased
Use IDs instead of source strings for message keying
-compress
Compress the QM files
-nounfinished
Do not include unfinished translations
-removeidentical
If the translated text is the same as
the source text, do not include the message
-markuntranslated <prefix>
If a message has no real translation, use the source text
prefixed with the given string instead
-project <filename>
Name of a file containing the project's description in JSON format.
Such a file may be generated from a .pro file using the lprodump tool.
-silent
Do not explain what is being done
-version
Display the version of lrelease and exit
Makefile:30791: recipe for target 'libgui/languages/be_BY.qm' failed
解决办法,我们自己用命令进行转换,这里参考iterate files,给出一个批量将.ts文件转换成.qm文件的.sh脚本:
DIRECTORY=.
for i in *.ts; do
lrelease $i
done
将这四行内容写到一个.sh文件中,置于octave-7.1.0/libgui/languages目录,添加可执行权限,即可将该目录下面的所有.ts文件转换为.qm文件。
ZLIB报错
configure的时候Z libraries能找到,但是编译的时候会报错找不到相关的函数uncompress2:
./../libinterp/corefcn/ls-mat5.cc: In function ‘std::__cxx11::string read_mat5_binary_element(std::istream&, const string&, bool, bool&, octave_value&)’:
./../libinterp/corefcn/ls-mat5.cc:535:67: error: ‘uncompress2’ was not declared in this scope
reinterpret_cast<Bytef *> (inbuf), &elt_len)
^
./../libinterp/corefcn/ls-mat5.cc:552:38: error: ‘uncompress2’ was not declared in this scope
&elt_len);
^
Makefile:18990: recipe for target 'libinterp/corefcn/libcorefcn_la-ls-mat5.lo' failed
解决办法:修改octave-7.1.0/libinterp/corefcn/ls-mat5.cc里面的代码,将
#if defined (HAVE_ZLIB)
改成
#if 0
绕过uncompress2。最后,成功编译。
Check & Install
make check && \
make install
通过绝对路径启动Octave:
$HOME/shiliu_octave/bin/octave --gui

用alias简化命令:
echo "alias shiliu_octave='$HOME/shiliu_octave/bin/octave --gui &'" >> ~/.bashrc
source $HOME/.bashrc
编译的Octave没有内置文本编辑器,需要安装第三方文本编辑器,可以选择Emacs。
参考链接
- https://wiki.octave.org/Building
- https://wiki.octave.org/Octave_for_Debian_systems#The_right_way
- https://lists.gnu.org/archive/html/help-octave/2016-08/msg00161.html
- macos - Octave configure cannot find Qt library on OS X - Stack Overflow
https://stackoverflow.com/questions/24281366/octave-configure-cannot-find-qt-library-on-os-x - GNU Octave - Bugs: bug #55282, QT_CPPFLAGS and QT_LDFLAGS… [Savannah]
https://savannah.gnu.org/bugs/?55282 - compiling - Trouble with Qt libraries while installing Gnu Octave 4.0.0 from source - Ask Ubuntu
https://askubuntu.com/questions/659236/trouble-with-qt-libraries-while-installing-gnu-octave-4-0-0-from-source - Find and replace text within multiple files - Ask Ubuntu
https://askubuntu.com/questions/84007/find-and-replace-text-within-multiple-files - ubuntu - Bash script to iterate files in directory and pattern match filenames - Stack Overflow
https://stackoverflow.com/questions/11185771/bash-script-to-iterate-files-in-directory-and-pattern-match-filenames
更多推荐



所有评论(0)