天天看点

Windows Vista编译Qtiplot0.9.7.14--附有Python脚本功能

经过4天的努力,我终于把QtiPlot_0.9.7.14这个版本的软件编译成功了,在此时此刻与广大开源爱好者一起分享,同时感谢“于湛的博客”中提到的方法,他的编译的方法虽然是适合于旧的版本,但是启发意义非同小可。终于通过这个软件让我真正进入了开源的新时代,可以说对于我的工作领域的扩大以及人生心结的解开有非常大的意义。

其实高中时候上了一门VB课,从此在我心里头就对程序有了心结,学的时候特别痛苦,大学的时候更是影响到了C语言的学习。参加工作后,我觉得自己一定要克服这个心结,于是对于各种语言都努力实现,终于在此时我学会了编译,再也不怕编程了。

好了,言归正传,开始讲述编译的过程。一定要做好长时间编译的准备,我用的是惠普HP6531,操作系统是Vista,每次编译最终的文件需要一个半小时。

1.首先从http://soft.proindependent.com/download.html把源代码下载下来,我下载的是QtiPlot_0.9.7.14这个版本,作者已经修改了很多的的bug,完善了很多。

2.把源代码解压缩到一个文件夹里,一定要注意这个文件的路径是全英文的,比如我的解压缩的路径就是这样的:I:/x/qtiplot-0.9.7.14,然后在这个路径里面列举以下的文件:

-3rdparty

-----liborigin -----QTeXEngine

-----qwt

-----qwtplot3d

-----zlib

-fitPlugins

-manual

-qtiplot

.gitignore

build.conf.example

Doxyfile

gpl_licence.txt

qtiplot.1

qtiplot.css

qtiplot.pro

qtiplot_logo.png

README.html

这个版本中的第三方插件感觉和以前的不同了,比如没有了EMFEngine,取而代之的是QtexEngine。我记得于湛博客中曾经提到编译EMFEngine也还挺复杂,现在好了,不用编译了。

首先要读源代码中的README.html,这个文件会交给你如何编译。

接下来按照说明将build.conf.example 改为build.conf,并正确设置其中一些库的路径。在文章的最后我附上了Qtiplot0.9.8.2的Build.conf和qtiplot.pro的具体内容以供大家参考。

好了,开始编译。

首先到了总目录下面(I:/x/qtiplot-0.9.7.14),然后输入qmake,回车;接着再输入mingw32-make,回车。执行完这个步骤你就可以等了,前提是第三方插件你都已经编译好了。

如果想让程序包含有Python脚本功能的话,一定要安装Python,SIP和PyQT。

第一步,目前(2010.09)最稳定的版本Python是2.5(而且源代码中的Python是按照2.5的语法写的),所以首先要安装Python2.5。

第二步,下载SIP-4.11,这个需要自己编译。首先打开cmd输入C:/Python25/python configure.py --platform win32-g++;然后打开“QT Command Prompt”在里面输入mingw32-make;最后输入mingw32-make -install。这样所有的文件就自动复制到了C:/Python25里面,最重要的一个文件是SIP.exe。

第三步,下载PyQt-4.7.6,这个也需要自己编译。首先打开cmd输入C:/Python25/python configure.py;然后打开“QT Command Prompt”在里面输入mingw32-make;最后输入mingw32-make -install。这样所有的文件就自动复制到了C:/Python25里面。

当添加了Python的功能后,运行Qtiplot的时候就一定要记住载入Python Configuration File,这3个文件就在源代码里面,如下:

/qtiplot/qti_wordlist.txt

/qtiplot/qtiplotrc.py

/qtiplot/qtiUtil.py

注意:运行Python的时候一定要注意以上三个文件不能放在中文的文件夹里面,否则无法运行程序。

在此处写一段简单的程序:如果想深入学习的话,请参开这里。

CreateObj.py

# create an empty table named "tony" with 5 rows and 2 columns:

t = newTable("tony", 5, 2)

# use defaults

t = newTable()

# create an empty matrix named "gina" with 42 rows and 23 columns:

#m = newMatrix("gina", 42, 23)

# use defaults

#m = newMatrix()

# create an empty graph window

g = newGraph()

# create a graph window named "test" with two layers disposed on a 2 rows x 1 column grid

g = newGraph("test", 2, 2, 1)

# create an empty 3D plot window with default title

#p = newPlot3D()

# create an empty note named "momo"

n = newNote("momo")

# use defaults

n = newNote()

最后附上

1.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

# Global lib path and libs which is ls always added at the end of LIBS

SYS_LIBS = -L/opt/local/lib

##########################################################

## 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

# 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

##########################################################

## Boost libraries (http://www.boost.org/)

##########################################################

# include path. leave it blank to use SYS_INCLUDE

BOOST_INCLUDEPATH = "C:/Program Files/boost/boost_1_42"

# link statically against a copy in 3rdparty/

unix: BOOST_LIBS = $$QTI_ROOT/3rdparty/boost/lib/libboost_date_time-gcc43-mt-1_38.a /

$$QTI_ROOT/3rdparty/boost/lib/libboost_thread-gcc43-mt-1_38.a

win32:BOOST_LIBS = "C:/Program Files/boost/boost_1_42/stage/lib/libboost_date_time-mgw44-mt.lib" /

"C:/Program Files/boost/boost_1_42/stage/lib/libboost_thread-mgw44-mt.lib"

# or dynamically against a system-wide installation

#BOOST_LIBS = -lboost_date_time-mt -lboost_thread-mt

##########################################################

## 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

##########################################################

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

##(http://www.codeproject.com/KB/office/ExcelFormat.aspx)

##########################################################

# include path.

#XLS_INCLUDEPATH = $$QTI_ROOT/3rdparty/ExcelFormat/

# link locally against a copy in 3rdparty/

#XLS_LIBS = $$QTI_ROOT/3rdparty/ExcelFormat/lib/libExcelFormat.a

###########################################################

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

# http://quazip.sourceforge.net/

###########################################################

# include path.

QUAZIP_INCLUDEPATH = $$QTI_ROOT/3rdparty/quazip/quazip/

# link locally against a copy in 3rdparty/

QUAZIP_LIBS = $$QTI_ROOT/3rdparty/quazip/lib/libquazip.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

##########################################################

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

# http://soft.proindependent.com/emf/index.html

##########################################################

# include path.

#EMF_ENGINE_INCLUDEPATH = $$QTI_ROOT/3rdparty/EmfEngine/src

# link locally against a copy in 3rdparty/

#EMF_ENGINE_LIBS = $$QTI_ROOT/3rdparty/EmfEngine/libEmfEngine.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

# Comment the following lines to disable donations start-up message.

#DEFINES         += QTIPLOT_SUPPORT

# 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

#win32: CONFIG   += console

}

2.qtiplot.pro

TEMPLATE = subdirs

SUBDIRS = fitPlugins /

3rdparty/qwt /

3rdparty/qwtplot3d /

qtiplot http://hi.baidu.com/kxw102/blog/item/3fc97e9ab9ab1fbbc8eaf4f9.html