[PyKDE] Help needed with SIP

Kaercher, Joerg JKaercher at bruker-axs.com
Sat Jun 9 00:51:57 BST 2001


Hi,

I want to use SIP to create Python bindings to a sample C++ Qt class I have
written, but whenever I try to import the module in Python I get the
following error message:

Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "b.py", line 6, in ?
    import libbc
ImportError: /usr/local/lib/python2.1/site-packages/libbcmodule.so:
undefined symbol: sipName_qt_destroyed

Any help is appreciated.

Joerg




Here are my source files, sip file, and makefile:

b.h:
#include <qpushbutton.h>
#include <qstring.h>
 
class b : public QPushButton {
    Q_OBJECT
 
public:
    b(QWidget* parent=0, const char* name=0);
    ~b();
 
public slots:
    void setNumber(const QString&);
 
private slots:
    void onButtonClicked();
 
private:
    float number;
 
signals:
    void result(const QString&);
};

**********

b.cpp:
#include "b.h"
 
b::b(QWidget* parent, const char* name) : QPushButton("&Cube", parent, name)
{
    number = 0.;
    connect(this, SIGNAL(clicked()), SLOT(onButtonClicked()));
}
 
b::~b() {
}
 
void b::setNumber(const QString& n) {
    bool ok;
    float newNumber = n.toFloat(&ok);
    if (ok) {
        number = newNumber;
    }
}
 
void b::onButtonClicked() {
    QString res;
    res.sprintf("%f", number*number*number);
    emit result(res);
}

**********

b.sip:
%Module b
 
%Import qt.sip
 
class b : QPushButton
{
%HeaderCode
#include "b.h"
%End
 
public:
    b(QWidget * /TransferThis/ = 0, const char * = 0);
 
public slots:
    void setNumber(const QString&);
 
signals:
    void result(const QString&);
};

**********

Makefile:
CXX = g++
CXXFLAGS = -I/usr/local/include/sip -I/usr/local/include/python2.1
-I/usr/lib/qt-2.2.4/include -I.
LDFLAGS = -L/usr/local/lib -L/usr/lib/qt-2.2.4/lib -lsip -lqt
-L/usr/X11R6/lib -lSM -lICE -lX11
 
all: libbcmodule.so
 
sip_helper: sip_helper.cpp
    $(CXX) $(CXXFLAGS) sip_helper.cpp -o sip_helper
 
sipbVersion.h: sip_helper
    ./sip_helper >sipbVersion.h
 
b.lo: b.cpp b.h
    /bin/sh libtool --mode=compile c++ -I. -I/usr/local/include/python2.1
-I/usr/local/include/sip -I/usr/lib/qt-2.2.4/include -I/usr/X11R6/include
-fno-exceptions -O2 -c -o b.lo b.cpp
 
sipbProxyb.h bcmodule.cpp sipbb.cpp sipbb.h: b.sip
    sip -I /usr/local/share/sip/qt -c . b.sip
 
bcmodule.moc: b.h
    moc -o bcmodule.moc b.h
 
moc_sipbProxyb.h: sipbProxyb.h sipbVersion.h
    c++ -E -I/usr/local/include/python2.1 -I/usr/local/include/sip
-I/usr/lib/qt-2.2.4/include -I/usr/X11R6/include sipbProxyb.h >
moc_sipbProxyb.h
 
sipbProxyb.moc: moc_sipbProxyb.h
    moc -o sipbProxyb.moc moc_sipbProxyb.h
 
bcmodule.lo: bcmodule.cpp bcmodule.moc sipbProxyb.moc sipbVersion.h
    /bin/sh libtool --mode=compile c++ -I. -I/usr/local/include/python2.1
-I/usr/local/include/sip -I/usr/lib/qt-2.2.4/include -I/usr/X11R6/include
-fno-exceptions -O2 -c -o bcmodule.lo bcmodule.cpp
 
sipbb.lo: sipbb.cpp
    /bin/sh libtool --mode=compile c++ -I. -I/usr/local/include/python2.1
-I/usr/local/include/sip -I/usr/lib/qt-2.2.4/include -I/usr/X11R6/include
-fno-exceptions -O2 -c -o sipbb.lo sipbb.cpp
 
libbcmodule.so: bcmodule.lo sipbb.lo b.lo
    /bin/sh libtool --mode=link c++ -fno-exceptions -O2 -o libbcmodule.la
-rpath /usr/local/lib/python2.1/site-packages -release 1.0 bcmodule.lo
sipbb.lo b.lo $(LDFLAGS)






More information about the PyQt mailing list