Compiling Octave 3.8&n…

本文提供了一份详细的指南,介绍如何在 Ubuntu 12.04 和 13.10 上从源码编译安装 Octave 3.8 版本。包括了下载源码、安装必备依赖包、配置编译选项等步骤,并针对不同版本的 Ubuntu 提供了差异化的操作指导。
http://blogs.bu.edu/mhirsch/2013/12/compiling-octave-3-8/

Note: The octave stable PPA finally (Apr 20 2014) has Octave 3.8.1.

https://launchpad.net/~octave/+archive/stable

I would recommend the normal user on Ubuntu 12.04 to consider using the PPA above, it will be much easier than the manual process below.
——————————————————————————————————————–
Download source:
wget -P ~/Downloads http://ftp.gnu.org/pub/gnu/octave/octave-3.8.2.tar.bz2

Extract to directory:
tar -C ~/Downloads -xvf ~/Downloads/octave-3.8*.tar.bz2

Prerequisites  (Ubuntu 13.10):
sudo apt-get install gfortran debhelper automake dh-autoreconf texinfo texlive-latex-base texlive-generic-recommended epstool transfig pstoedit libreadline-dev libncurses5-dev gperf libhdf5-serial-dev libblas-dev liblapack-dev libfftw3-dev texi2html less libpcre3-dev flex libglpk-dev libsuitesparse-dev gawk ghostscript libcurl4-gnutls-dev libqhull-dev desktop-file-utils libfltk1.3-dev libgl2ps-dev libgraphicsmagick++1-dev libftgl-dev libfontconfig1-dev libqrupdate-dev libarpack2-dev dh-exec libqt4-dev libqscintilla2-dev default-jdk dpkg-dev gnuplot-x11 libbison-dev libxft-dev llvm-dev

Prerequisites (Ubuntu 12.04.4):
sudo apt-get install gfortran debhelper automake dh-autoreconf texinfo texlive-latex-base texlive-generic-recommended epstool transfig pstoedit libreadline-dev libncurses5-dev gperf libhdf5-serial-dev libblas-dev liblapack-dev libfftw3-dev texi2html less libpcre3-dev flex libglpk-dev libsuitesparse-dev gawk ghostscript libcurl4-gnutls-dev libqhull-dev desktop-file-utils libfltk1.3-dev libgl2ps-dev libgraphicsmagick++1-dev libftgl-dev libfontconfig1-dev libqrupdate-dev libarpack2-dev dh-exec libqt4-dev libqscintilla2-dev default-jdk dpkg-dev gnuplot-x11 libbison-dev libxft-dev

Note: for Ubuntu 12.04, you will have to get LLVM 3.2 Binaries and extract somewhere — you’ll manually link to these in the configure step below.
E.g.
wget -P ~/Downloads http://llvm.org/releases/3.2/clang+llvm-3.2-x86_64-linux-ubuntu-12.04.tar.gz
tar -C ~/Downloads xvf ~/Downloads/clang+llvm-3.2-x86_64-linux-ubuntu-12.04.tar.gz

——–


cd ~/Downloads/octave-3.8.1

 

(Ubuntu 13.10)

./configure --enable-jit --prefix=/opt/octave3.8

(Ubuntu 12.04.4)
./configure --enable-jit --prefix=/opt/octave3.8 LLVM_CONFIG=~/Downloads/clang+llvm-3.2-x86_64-linux-ubuntu-12.04/bin/llvm-config

You may get the error:
configure: WARNING: JAVA_HOME environment variable not initialized. Auto-detection will proceed but is unreliable.
On my Ubuntu 13.10 PCs, Java was found automatically despite this error.


make

This takes about 30 minutes to compile on a Sandy Bridge i7-2600 CPU.


make check

I get:
PASS 11503
FAIL 0
XFAIL 7


sudo make install
sudo ln -s /opt/octave3.8/bin/octave /usr/local/bin/octave3.8

Now to run Octave 3.8 with GUI, at Terminal type:
octave3.8 --force-gui

You can of course make a bash alias to always add that –force-gui for you.

nano ~/.bash_aliases
and add the line
alias octave38="octave3.8 --force-gui"

Notes re: LLVM version:
Ubuntu 13.10 llvm-dev is currently LLVM 3.2. As of this comment from mtmiller on January 2014, Octave 3.8 requires LLVM 3.2 or 3.3 to compile:

https://savannah.gnu.org/bugs/?41061#comment9

Ubuntu 12.04 defaults to LLVM 2.9, which is now too old for Octave 3.8. I would suggest considering the Pre-Built Binaries

Note: Ubuntu 14.04 has Octave 3.8 by default – yay!

Note: As Ian notes in the comments, surf() seems to be broken with the otherwise fast and great FLTK plotting. As Ian notes, when you need surf(), circumvent this problem by falling back to gnuplot by typing in Octave:
graphics_toolkit('gnuplot')

Reference (Jordi G. H.):

http://octave.1599824.n4.nabble.com/Please-release-RC1-to-octave-unstable-PPA-td4659924.html

### 使用 `make` 和 `make install` 进行软件编译和安装 #### 编译过程中的 Makefile 结构 Makefile 是由一系列规则组成的文件,每条规则定义了一个目标(target),该目标依赖于其他文件(pre-requisites),并通过特定命令(command)来更新这些目标。当运行不带参数的 `make` 时,默认会执行名为 "all" 的目标[^3]。 ```bash target: prerequisites... command ``` #### 安装所需开发包 在某些情况下,在开始构建之前可能需要先安装一些必要的库和支持工具。例如,在基于 Debian 的系统上准备环境时,可能会涉及到如下一组开发包的安装: ```shell sudo apt-get update && sudo apt-get install -y \ make \ libxml2-dev \ libcurl4-openssl-dev \ libjpeg-dev \ libpng-dev \ libxpm-dev \ libmysqlclient-dev \ libicu-dev \ libfreetype6-dev \ libxslt-dev \ libssl-dev \ libbz2-dev \ libgmp-dev \ libmcrypt-dev \ libpspell-dev \ recode-dev \ apache2-dev ``` 上述命令确保了所有必需组件的存在,以便顺利完成配置阶段的工作[^2]。 #### 执行编译操作 一旦准备工作完成并进入了源码目录,则可以通过简单的 `make` 来启动默认的目标编译流程。这通常意味着按照项目提供的 Makefile 中指定的方式去创建可执行程序或其他产物。 对于 C/C++ 类型的应用来说,典型的编译链可能是这样的: 1. 将 `.c` 或者 `.cpp` 文件转换成对象文件(`*.o`); 2. 链接多个对象文件以及外部链接库生成最终的二进制文件; 具体实例可以参见下面这段伪代码表示的过程: ```python print("Compiling source files into object files...") gcc -c hello.c # Compile only; do not link yet. print("Linking objects together to form executable.") gcc -o hello.exe hello.o # Link the compiled code with any required libraries. ``` #### 实施安装步骤 成功编译之后,如果希望把新建立好的应用程序放置到系统的标准路径下(比如 `/usr/local/bin/`),那么就可以调用 `make install` 。此指令将会依据 Makefile 内部设定的位置复制相应的文件至适当的地方,并设置权限等属性以供全局访问。 需要注意的是,由于此类动作往往涉及到了受保护区域的操作,因此一般都需要超级用户的授权才能顺利实施。所以实际应用时常配合 `sudo` 工具来进行提权处理,像这样: ```shell sudo make install ``` 然而,有时当前用户并没有被赋予足够的权利去做这件事,这时就会遇到类似于“not in the sudoers file”的错误提示信息[^1]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值