maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   PyQt4 embedding in C++ application (https://talk.maemo.org/showthread.php?t=53386)

gri 2010-05-23 10:26

PyQt4 embedding in C++ application
 
Hello,

I'm testing the python embedding with PyQt4 but unfortunately the loading in scratchbox fails with a strange message. The same code runs fine on Windows XP.

Code:

Traceback (most recent call last):
  File "/home/gri/web2sms-0.1.1/dist/providers/provider_test.py", line 22, in <module>
    from PyQt4 import QtCore, QtGui
ImportError: /usr/lib/python2.5/site-packages/PyQt4/QtCore.so: undefined symbol: PyProperty_Type

Google only finds one debian bugreport related to this. But there's no answer :(

So maybe someone here knows why this error happens.

C++ source of python initialization
Source of python script

gri 2010-05-24 22:05

Re: PyQt4 embedding in C++ application
 
Small update on this.

I found out funny things about the following lines of code:
Code:

Py_Initialize();

PyRun_SimpleString("from PyQt4 import QtCore, QtGui");
if ( PyErr_Occurred() )
  PyErr_Print(); 

Py_Finalize();

Run these lines in the main program: works.
Run these lines in a shared library which the main program loads at startup: works.
Run these lines in a shared library which is loaded using QLibraryLoader at runtime: the error described in the first post :(

So what now? Is there anything magic I don't know when using shared library runtime loading?

:-) 2010-05-24 23:14

Re: PyQt4 embedding in C++ application
 
Quote:

Originally Posted by gri (Post 674052)
So what now? Is there anything magic I don't know when using shared library runtime loading?

Try playing with the load hints if you're using QLibrary to load Python, especially ExportExternalSymbolsHint:

http://doc.qt.nokia.com/4.6/qlibrary.html#LoadHint-enum

gri 2010-05-25 19:30

Re: PyQt4 embedding in C++ application
 
Thanks mate! I should have known that but overlooked it all the time :eek:

You made my day :)


All times are GMT. The time now is 12:12.

vBulletin® Version 3.8.8