[PyQt] help needed with SIP

Hazen Babcock hbabcock at mac.com
Sun Apr 26 03:07:06 BST 2009


Hello,

I'm trying to use SIP to wrap a Qt widget provided by the PLplot
plotting library.

The Qt widget driver library is located here:
/usr/local/lib/plplot5.9.2/driversd/qt.so

The plplot library itself is located here:
/usr/local/lib/libplplotd.so

And the header file for qt.so in here:
/usr/local/include/plplot/qt.h

Configure seems to work ok, but then the make fails:

hbabcock at hbabcock-laptop:~/Python/qt-test/v3$ python 
plplot_pyqt_configure.py
hbabcock at hbabcock-laptop:~/Python/qt-test/v3$ make
g++ -c -I/usr/include/qt4/QtGui -pipe -fPIC -O2 -Wall -W -D_REENTRANT 
-DQT_NO_DEBUG -DQT_CORE_LIB -I. -I/usr/include/python2.5 
-I/usr/share/qt4/mkspecs/default -I/usr/include/qt4/QtCore 
-I/usr/include/qt4 -I/usr/X11R6/include -o sipplplot_pyqtcmodule.o 
sipplplot_pyqtcmodule.cpp
sipplplot_pyqtcmodule.cpp: In function ‘PyObject* 
func_plfreeqtdev(PyObject*, PyObject*)’:
sipplplot_pyqtcmodule.cpp:88: error: ‘plfreeqtdev’ was not declared in 
this scope
sipplplot_pyqtcmodule.cpp: In function ‘PyObject* 
func_plsetqtdev(PyObject*, PyObject*)’:
sipplplot_pyqtcmodule.cpp:109: error: ‘QtExtWidget’ was not declared in 
this scope
sipplplot_pyqtcmodule.cpp:109: error: ‘a0’ was not declared in this scope
sipplplot_pyqtcmodule.cpp:114: error: ‘plsetqtdev’ was not declared in 
this scope
make: *** [sipplplot_pyqtcmodule.o] Error 1

It looks to me like maybe it is not finding the qt.h file?


This is the sip file:

%Module plplot_pyqt 0

%Import QtCore/QtCoremod.sip
%Import QtGui/QtGuimod.sip

class QtPLDriver
{

%TypeHeaderCode
#include "plplot/qt.h"
%End

   public:
     QtPLDriver(int i_iWidth=QT_DEFAULT_X, int i_iHeight=QT_DEFAULT_Y);
     virtual ~QtPLDriver();
};

class QtPLWidget: QWidget, QtPLDriver
{

%TypeHeaderCode
#include "plplot/qt.h"
%End

   public:
     QtPLWidget(int i_iWidth=QT_DEFAULT_X, int i_iHeight=QT_DEFAULT_Y, 
QWidget* parent=0);
     virtual ~QtPLWidget();
};

class QtExtWidget: QtPLWidget
{

%TypeHeaderCode
#include "plplot/qt.h"
%End

   public:
     QtExtWidget(int i_iWidth=QT_DEFAULT_X, int i_iHeight=QT_DEFAULT_Y, 
QWidget* parent=0);
     virtual ~QtExtWidget();
};

void plsetqtdev(QtExtWidget* widget);

void plfreeqtdev();


And this is the configure file:

import os
import sipconfig
from PyQt4 import pyqtconfig

# The name of the SIP build file generated by SIP and used by the build
# system.
build_file = "plplot_pyqt.sbf"

# Get the PyQt configuration information.
config = pyqtconfig.Configuration()

# Get the extra SIP flags needed by the imported qt module.  Note that
# this normally only includes those flags (-x and -t) that relate to SIP's
# versioning system.
qt_sip_flags = config.pyqt_sip_flags

# Run SIP to generate the code.  Note that we tell SIP where to find the qt
# module's specification files using the -I flag.
os.system(" ".join([config.sip_bin, "-c", ".", "-b", build_file, "-I",
                     config.pyqt_sip_dir, qt_sip_flags, "plplot_pyqt.sip"]))

# We are going to install the SIP specification file for this module and
# its configuration module.
installs = []

installs.append(["plplot_pyqt.sip", os.path.join(config.default_sip_dir,
                                            "plplot_pyqt")])

# Create the Makefile.  The QtModuleMakefile class provided by the
# pyqtconfig module takes care of all the extra preprocessor, compiler and
# linker flags needed by the Qt library.
makefile = pyqtconfig.QtCoreModuleMakefile(
     configuration=config,
     build_file=build_file,
     installs=installs
     )

# Add the library we are wrapping.  The name doesn't include any platform
# specific prefixes or extensions (e.g. the "lib" prefix on UNIX, or the
# ".dll" extension on Windows).
#makefile.LFLAGS.append("-L../c++")
makefile.extra_cxxflags = ["-I/usr/include/qt4/QtGui"]
makefile.extra_libs = ["/usr/local/lib/plplot5.9.2/driversd/qt.so", 
"plplotd"]

# Generate the Makefile itself.
makefile.generate()


Any ideas about what I am doing wrong would be much appreciated.

Thanks!
-Hazen




More information about the PyQt mailing list