在Ubuntu 12.04下编译qtiplot

时间:2023-03-08 16:15:43

不在windows下,再加上不想用盗版,所以需要一个origin的替代品——qtiplot。虽然我非常抵抗用这种不停点来点去的软件,用R的ggplot2画图多好啊,高效、优雅、漂亮,但是终抵不过老板一句“这个图你用origin画”。

有公司编译出了qtiplot的deb包,但是缺少一些功能,比如不能导出数据,这太坑爹了!好吧,我只有自己来编译。哪儿知道它有太多的依赖,并且头文件包含还不能紧跟时代。 解压源代码后复制build.conf.example为build.conf,然后在里面把库的链接改成系统内的目录,不要用它那个3rdparty的目录。然后就是qmake产生Makefile,接着一边make一边看出现什么错误提示,比如找不到头文件啊,这一般是因为某些依赖的包没有安装,使用Ubuntu的包内容搜索功能找到包含这个头文件的包,然后apt-get安装上。

注意:安装好包过后还是提示找不到头文件,就是文件包含位置不对,要么手动更改源代码将头文件位置改对,要么在build.conf里面添加一个包含目录。

唯一需要修改源代码的地方就是在./3rdparty/qwtplot3d/include/qwt3d_openglhelper.h中包含#include <GL/glu.h>

对python脚本的支持实在是弄不好了,需要sip和pyqt来生成一个头文件sipAPIqti.h,这一步我没有成功。

应该是需要下面这些包依赖:

sudo apt-get install libqt4-opengl-dev libmuparser-dev libtamuanova-dev libalglib-dev libqtassistantclient-dev libqtexengine-dev python-dev

那个手册没有编译安装,为了装它得下个latex,太不值了,所以在生成makefile后直接把手册的那部分全部删掉。

最后,关于qtiplot的文件关联问题。在Ubuntu 12.04下,如果右键选取一个新的应用程序来打开该文件,必须要求该mime类型在/usr/share/applications/下有一个对应的desktop文件,同时,该desktop文件中Exec=一栏中命令后面需要带有参数%f以用来表示此程序后面可以跟文件名。同时,在/usr/share/mime/application/目录下会有一个xml文件标示该mime类型。

下面直接把我的build.conf传上来。

isEmpty( QTI_ROOT ) {
  message( "each file including this config needs to set QTI_ROOT to the dir containing this file!" )
}

##########################################################
##     System specific configuration
##########################################################

# Global include path which is always added at the end of the INCLUDEPATH
SYS_INCLUDEPATH = /opt/local/include /usr/include/python2.7 /usr/include/muParser /usr/include/tamu_anova /usr/include/qt4/QtAssistant
# Global lib path and libs which is ls always added at the end of LIBS
SYS_LIBS = -L/opt/local/lib -lGLU

##########################################################
## zlib (http://www.zlib.net/)
##########################################################

# include path. leave it blank to use SYS_INCLUDE
ZLIB_INCLUDEPATH = $QTI_ROOT/3rdparty/zlib/

##########################################################
## muParser (http://muparser.sourceforge.net/)
##########################################################

# include path. leave it blank to use SYS_INCLUDE
MUPARSER_INCLUDEPATH = $QTI_ROOT/3rdparty/muparser/include
# link statically against a copy in 3rdparty/
#MUPARSER_LIBS =  $QTI_ROOT/3rdparty/muparser/lib/libmuparser.a
# or dynamically against a system-wide installation
MUPARSER_LIBS = -lmuparser

##########################################################
## GNU Sientific Library (http://www.gnu.org/software/gsl/)
##########################################################

# include path. leave it blank to use SYS_INCLUDE
#GSL_INCLUDEPATH = $QTI_ROOT/3rdparty/gsl/include
GSL_INCLUDEPATH =
# link statically against a copy in 3rdparty/
#GSL_LIBS =  $QTI_ROOT/3rdparty/gsl/lib/libgsl.a \
           $QTI_ROOT/3rdparty/gsl/lib/libgslcblas.a
# or dynamically against a system-wide installation
GSL_LIBS = -lgsl -lgslcblas

##########################################################
## QWT - use local copy till upstream catches up
# http://qwt.sourceforge.net/index.html
##########################################################

# include path.
QWT_INCLUDEPATH =  $QTI_ROOT/3rdparty/qwt/src
# link locally against a copy in 3rdparty/
QWT_LIBS = $QTI_ROOT/3rdparty/qwt/lib/libqwt.a

##########################################################
## QwtPlot3D - use local copy till upstream catches up
# http://qwtplot3d.sourceforge.net/
##########################################################

# include path.
QWT3D_INCLUDEPATH =  $QTI_ROOT/3rdparty/qwtplot3d/include
# link locally against a copy in 3rdparty/
win32:QWT3D_LIBS = $QTI_ROOT/3rdparty/qwtplot3d/lib/qwtplot3d.dll
unix:QWT3D_LIBS =  $QTI_ROOT/3rdparty/qwtplot3d/lib/libqwtplot3d.a

##########################################################
## libpng - optional. you don't have to set these variables
##########################################################

# include path. leave it blank to use SYS_INCLUDE
LIBPNG_INCLUDEPATH = $QTI_ROOT/3rdparty/libpng/
# link statically against a copy in 3rdparty/
#LIBPNG_LIBS =  $QTI_ROOT/3rdparty/libpng/libpng.a
# or dynamically against a system-wide installation
LIBPNG_LIBS = -lpng

##########################################################
## QTeXEngine - optional. you don't have to set these variables
# http://soft.proindependent.com/qtexengine/
##########################################################

# include path.
TEX_ENGINE_INCLUDEPATH = $QTI_ROOT/3rdparty/QTeXEngine/src
# link locally against a copy in 3rdparty/
TEX_ENGINE_LIBS =  $QTI_ROOT/3rdparty/QTeXEngine/libQTeXEngine.a

##########################################################
## ALGLIB (2.6) - optional. you don't have to set these variables
# http://www.alglib.net/
##########################################################

# include path.
ALGLIB_INCLUDEPATH = $QTI_ROOT/3rdparty/alglib/
# link locally against a copy in 3rdparty/
ALGLIB_LIBS = /usr/lib/libalglib.a

##########################################################
## TAMUANOVA - optional. you don't have to set these variables
# http://www.stat.tamu.edu/~aredd/tamuanova/
##########################################################

# include path.
TAMUANOVA_INCLUDEPATH = $QTI_ROOT/3rdparty/tamu_anova/
# link locally against a copy in 3rdparty/
TAMUANOVA_LIBS = /usr/lib/libtamuanova.a

##########################################################
## python - only used if python is needed
##########################################################

# the python interpreter to use
# (unix only, windows will use what ever is configured to execute .py files!)
PYTHON = python

##########################################################
## Qt tools - allows to use specific versions
##########################################################

LUPDATE = lupdate
LRELEASE = lrelease

############################################################
##  Target specific configuration: configure Qtiplot itself
############################################################

contains( TARGET, qtiplot ) {
  # building without muParser doesn't work yet
  SCRIPTING_LANGS += muParser
  #SCRIPTING_LANGS += Python

  # a console displaying output of scripts; particularly useful on Windows
  # where running QtiPlot from a terminal is inconvenient
  DEFINES         += SCRIPTING_CONSOLE

  #DEFINES         += QTIPLOT_DEMO

  # Uncomment the following line if you want to perform a custom installation using the *.path variables defined in ./qtiplot.pro.
  #CONFIG          += CustomInstall

  # Uncomment the following line if you want to build QtiPlot as a browser plugin (not working on Internet Explorer).
  #CONFIG          += BrowserPlugin

  CONFIG          += release
  #CONFIG          += debug

  # Uncomment the following line if you want to link statically against Qt.
  #CONFIG           += StaticBuild
  #win32: CONFIG   += console
}

 http://blog.uorz.me/2013/07/11/%E5%9C%A8Ubuntu-12.04%E4%B8%8B%E7%BC%96%E8%AF%91qtiplot.html