Yaşar Arabacı | 1 Jul 2011 10:24
Picon
Gravatar

translation of ui


Hi,

I was wondering how can I generate translation file for a ui generated by QtDesigner. I have no early experience of using translations, so I can't figure it out how to make this work. Should I mark strings in my main module or  does QtDesigner somehow provide it for me?
<div>
<br>Hi,<br><br>I was wondering how can I generate translation file for a ui generated by QtDesigner. I have no early experience of using translations, so I can't figure it out how to make this work. Should I mark strings in my main module or&nbsp; does QtDesigner somehow provide it for me?<br>
</div>
Yaşar Arabacı | 1 Jul 2011 11:08
Picon
Gravatar

Fwd: translation of ui

I accidentally mailed below message only to Sebastian, repostion to groups.

---------- Yönlendirilmiş ileti ----------
Kimden: Yaşar Arabacı <yasar11732 <at> gmail.com>
Tarih: 01 Temmuz 2011 12:07
Konu: Re: [PyQt] translation of ui
Kime: Sebastian Wiesner <lunaryorn <at> googlemail.com>


Thanks, appearantly I also needed to create a .pro file for pylupdate to know which files to convert to. I created a language file and translated it, but how would my application use that translation file?

01 Temmuz 2011 11:44 tarihinde Sebastian Wiesner <lunaryorn <at> googlemail.com> yazdı:

2011/7/1 Yaşar Arabacı <yasar11732 <at> gmail.com>:
>
> Hi,
>
> I was wondering how can I generate translation file for a ui generated by
> QtDesigner. I have no early experience of using translations, so I can't
> figure it out how to make this work. Should I mark strings in my main module
> or  does QtDesigner somehow provide it for me?

You don't need to "mark" strings in UI files.  Just use "pylupdate4"
on UI files as you would use it on python files, and translations will
be extracted from UI files, too.  If you load or compile UI files,
PyQt generates the necessary code to translate the user interface.

Sebastian Wiesner


<div>
<p>I accidentally mailed below message only to Sebastian, repostion to groups.<br><br></p>
<div class="gmail_quote">---------- Y&ouml;nlendirilmi&#351; ileti ----------<br>Kimden: Ya&#351;ar Arabac&#305; <span dir="ltr">&lt;<a href="mailto:yasar11732 <at> gmail.com">yasar11732 <at> gmail.com</a>&gt;</span><br>
Tarih: 01 Temmuz 2011 12:07<br>Konu: Re: [PyQt] translation of ui<br>Kime: Sebastian Wiesner &lt;<a href="mailto:lunaryorn <at> googlemail.com">lunaryorn <at> googlemail.com</a>&gt;<br><br><br>Thanks, appearantly I also needed to create a .pro file for pylupdate to know which files to convert to. I created a language file and translated it, but how would my application use that translation file?<br><br><div class="gmail_quote">
01 Temmuz 2011 11:44 tarihinde Sebastian Wiesner <span dir="ltr">&lt;<a href="mailto:lunaryorn <at> googlemail.com" target="_blank">lunaryorn <at> googlemail.com</a>&gt;</span> yazd&#305;:<div>
<div></div>
<div class="h5">
<br><blockquote class="gmail_quote">

2011/7/1 Ya&#351;ar Arabac&#305; &lt;<a href="mailto:yasar11732 <at> gmail.com" target="_blank">yasar11732 <at> gmail.com</a>&gt;:<br><div>
<div></div>
<div>&gt;<br>
&gt; Hi,<br>
&gt;<br>
&gt; I was wondering how can I generate translation file for a ui generated by<br>
&gt; QtDesigner. I have no early experience of using translations, so I can't<br>
&gt; figure it out how to make this work. Should I mark strings in my main module<br>
&gt; or&nbsp; does QtDesigner somehow provide it for me?<br><br>
</div>
</div>You don't need to "mark" strings in UI files. &nbsp;Just use "pylupdate4"<br>
on UI files as you would use it on python files, and translations will<br>
be extracted from UI files, too. &nbsp;If you load or compile UI files,<br>
PyQt generates the necessary code to translate the user interface.<br><br>
Sebastian Wiesner<br>
</blockquote>
</div>
</div>
</div>
<br>
</div>
<br>
</div>
Sebastian Wiesner | 1 Jul 2011 11:17
Gravatar

Re: Fwd: translation of ui

2011/7/1 Yaşar Arabacı <yasar11732 <at> gmail.com>:
> Thanks, appearantly I also needed to create a .pro file for pylupdate to
> know which files to convert to.

Alternatively you can specifiy the files to translate and the
translations to update on the command line:

pylupdate4 <ui_files> <python_files> -ts <translation_files>

> I created a language file and translated it, but how would my application use that translation file?

Use "lrelease" from Qt [1] to compile the translations, and deploy the
compiled translations along with your program.  In your program you
need to create a "QTranslator" [2] to load these compiled
translations.  There a different ways of deploying the translations
(e.g. as distutils package data), but the easiest is probably to
include them as resource (using "pyrcc4").

You should read the "Qt Linguist" manual [3], which describes the Qt
translation process in detail, and the corresponding chapter in the
PyQt Reference Guide [4], which describes the PyQt specific
differences to this process.

[1] http://doc.qt.nokia.com/latest/linguist-manager.html#lrelease
[2] http://doc.qt.nokia.com/latest/qtranslator.html#details
[3] http://doc.qt.nokia.com/latest/linguist-manual.html
[4] http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/i18n.html
Yaşar Arabacı | 1 Jul 2011 11:37
Picon
Gravatar

Re: Fwd: translation of ui

That works like a charm thanks :)


01 Temmuz 2011 12:17 tarihinde Sebastian Wiesner <lunaryorn <at> googlemail.com> yazdı:
2011/7/1 Yaşar Arabacı <yasar11732 <at> gmail.com>:
> Thanks, appearantly I also needed to create a .pro file for pylupdate to
> know which files to convert to.

Alternatively you can specifiy the files to translate and the
translations to update on the command line:

pylupdate4 <ui_files> <python_files> -ts <translation_files>

> I created a language file and translated it, but how would my application use that translation file?

Use "lrelease" from Qt [1] to compile the translations, and deploy the
compiled translations along with your program.  In your program you
need to create a "QTranslator" [2] to load these compiled
translations.  There a different ways of deploying the translations
(e.g. as distutils package data), but the easiest is probably to
include them as resource (using "pyrcc4").

You should read the "Qt Linguist" manual [3], which describes the Qt
translation process in detail, and the corresponding chapter in the
PyQt Reference Guide [4], which describes the PyQt specific
differences to this process.

[1] http://doc.qt.nokia.com/latest/linguist-manager.html#lrelease
[2] http://doc.qt.nokia.com/latest/qtranslator.html#details
[3] http://doc.qt.nokia.com/latest/linguist-manual.html
[4] http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/i18n.html

<div>
<p>That works like a charm thanks :)<br><br><br></p>
<div class="gmail_quote">01 Temmuz 2011 12:17 tarihinde Sebastian Wiesner <span dir="ltr">&lt;<a href="mailto:lunaryorn <at> googlemail.com">lunaryorn <at> googlemail.com</a>&gt;</span> yazd&#305;:<br><blockquote class="gmail_quote">
<div class="im">2011/7/1 Ya&#351;ar Arabac&#305; &lt;<a href="mailto:yasar11732 <at> gmail.com">yasar11732 <at> gmail.com</a>&gt;:<br>
</div>
<div class="im">&gt; Thanks, appearantly I also needed to create a .pro file for pylupdate to<br>
&gt; know which files to convert to.<br><br>
</div>Alternatively you can specifiy the files to translate and the<br>
translations to update on the command line:<br><br>
pylupdate4 &lt;ui_files&gt; &lt;python_files&gt; -ts &lt;translation_files&gt;<br><div class="im">
<br>
&gt; I created a language file and translated it, but how would my application use that translation file?<br><br>
</div>Use "lrelease" from Qt [1] to compile the translations, and deploy the<br>
compiled translations along with your program. &nbsp;In your program you<br>
need to create a "QTranslator" [2] to load these compiled<br>
translations. &nbsp;There a different ways of deploying the translations<br>
(e.g. as distutils package data), but the easiest is probably to<br>
include them as resource (using "pyrcc4").<br><br>
You should read the "Qt Linguist" manual [3], which describes the Qt<br>
translation process in detail, and the corresponding chapter in the<br>
PyQt Reference Guide [4], which describes the PyQt specific<br>
differences to this process.<br><br>
[1] <a href="http://doc.qt.nokia.com/latest/linguist-manager.html#lrelease" target="_blank">http://doc.qt.nokia.com/latest/linguist-manager.html#lrelease</a><br>
[2] <a href="http://doc.qt.nokia.com/latest/qtranslator.html#details" target="_blank">http://doc.qt.nokia.com/latest/qtranslator.html#details</a><br>
[3] <a href="http://doc.qt.nokia.com/latest/linguist-manual.html" target="_blank">http://doc.qt.nokia.com/latest/linguist-manual.html</a><br>
[4] <a href="http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/i18n.html" target="_blank">http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/i18n.html</a><br>
</blockquote>
</div>
<br>
</div>
Yaşar Arabacı | 1 Jul 2011 11:52
Picon
Gravatar

Re: Fwd: translation of ui


Hi, me again :)

I got it working but wanted to get an affimation, what do you think of this approach?

if __name__ == "__main__":
    from locale import getlocale
    from os.path import exists
    app = QtGui.QApplication(sys.argv)
    if getlocale()[0]:
        if exists("translations/" + getlocale()[0] + ".qm"):
            translator = QtCore.QTranslator(app)
            translator.load(getlocale()[0] + ".qm", "translations")
            app.installTranslator(translator)
    window = MainWindow()
    window.show()
    sys.exit(app.exec_())
01 Temmuz 2011 12:37 tarihinde Yaşar Arabacı <yasar11732 <at> gmail.com> yazdı:
That works like a charm thanks :)


01 Temmuz 2011 12:17 tarihinde Sebastian Wiesner <lunaryorn <at> googlemail.com> yazdı:

2011/7/1 Yaşar Arabacı <yasar11732 <at> gmail.com>:
> Thanks, appearantly I also needed to create a .pro file for pylupdate to
> know which files to convert to.

Alternatively you can specifiy the files to translate and the
translations to update on the command line:

pylupdate4 <ui_files> <python_files> -ts <translation_files>

> I created a language file and translated it, but how would my application use that translation file?

Use "lrelease" from Qt [1] to compile the translations, and deploy the
compiled translations along with your program.  In your program you
need to create a "QTranslator" [2] to load these compiled
translations.  There a different ways of deploying the translations
(e.g. as distutils package data), but the easiest is probably to
include them as resource (using "pyrcc4").

You should read the "Qt Linguist" manual [3], which describes the Qt
translation process in detail, and the corresponding chapter in the
PyQt Reference Guide [4], which describes the PyQt specific
differences to this process.

[1] http://doc.qt.nokia.com/latest/linguist-manager.html#lrelease
[2] http://doc.qt.nokia.com/latest/qtranslator.html#details
[3] http://doc.qt.nokia.com/latest/linguist-manual.html
[4] http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/i18n.html


<div>
<br>Hi, me again :)<br><br>I got it working but wanted to get an affimation, what do you think of this approach?<br><br>if __name__ == "__main__":<br>&nbsp;&nbsp;&nbsp; from locale import getlocale<br>&nbsp;&nbsp;&nbsp; from os.path import exists<br>
&nbsp;&nbsp;&nbsp; app = QtGui.QApplication(sys.argv)<br>&nbsp;&nbsp;&nbsp; if getlocale()[0]:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if exists("translations/" + getlocale()[0] + ".qm"):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; translator = QtCore.QTranslator(app)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; translator.load(getlocale()[0] + ".qm", "translations")<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; app.installTranslator(translator)<br>&nbsp;&nbsp;&nbsp; window = MainWindow()<br>&nbsp;&nbsp;&nbsp; window.show()<br>&nbsp;&nbsp;&nbsp; sys.exit(app.exec_())<br><div class="gmail_quote">01 Temmuz 2011 12:37 tarihinde Ya&#351;ar Arabac&#305; <span dir="ltr">&lt;<a href="mailto:yasar11732 <at> gmail.com">yasar11732 <at> gmail.com</a>&gt;</span> yazd&#305;:<br><blockquote class="gmail_quote">That works like a charm thanks :)<br><br><br><div class="gmail_quote">01 Temmuz 2011 12:17 tarihinde Sebastian Wiesner <span dir="ltr">&lt;<a href="mailto:lunaryorn <at> googlemail.com" target="_blank">lunaryorn <at> googlemail.com</a>&gt;</span> yazd&#305;:<div>
<div></div>
<div class="h5">
<br><blockquote class="gmail_quote">
<div>2011/7/1 Ya&#351;ar Arabac&#305; &lt;<a href="mailto:yasar11732 <at> gmail.com" target="_blank">yasar11732 <at> gmail.com</a>&gt;:<br>
</div>
<div>&gt; Thanks, appearantly I also needed to create a .pro file for pylupdate to<br>
&gt; know which files to convert to.<br><br>
</div>Alternatively you can specifiy the files to translate and the<br>
translations to update on the command line:<br><br>
pylupdate4 &lt;ui_files&gt; &lt;python_files&gt; -ts &lt;translation_files&gt;<br><div>
<br>
&gt; I created a language file and translated it, but how would my application use that translation file?<br><br>
</div>Use "lrelease" from Qt [1] to compile the translations, and deploy the<br>
compiled translations along with your program. &nbsp;In your program you<br>
need to create a "QTranslator" [2] to load these compiled<br>
translations. &nbsp;There a different ways of deploying the translations<br>
(e.g. as distutils package data), but the easiest is probably to<br>
include them as resource (using "pyrcc4").<br><br>
You should read the "Qt Linguist" manual [3], which describes the Qt<br>
translation process in detail, and the corresponding chapter in the<br>
PyQt Reference Guide [4], which describes the PyQt specific<br>
differences to this process.<br><br>
[1] <a href="http://doc.qt.nokia.com/latest/linguist-manager.html#lrelease" target="_blank">http://doc.qt.nokia.com/latest/linguist-manager.html#lrelease</a><br>
[2] <a href="http://doc.qt.nokia.com/latest/qtranslator.html#details" target="_blank">http://doc.qt.nokia.com/latest/qtranslator.html#details</a><br>
[3] <a href="http://doc.qt.nokia.com/latest/linguist-manual.html" target="_blank">http://doc.qt.nokia.com/latest/linguist-manual.html</a><br>
[4] <a href="http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/i18n.html" target="_blank">http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/i18n.html</a><br>
</blockquote>
</div>
</div>
</div>
<br>
</blockquote>
</div>
<br>
</div>
Demetrius Cassidy | 1 Jul 2011 18:45
Picon

Re: Weird pyqtSignal behaviour

On WinXP Pro and Python 2.7.1 this is what I get:

>>> class CX(QtCore.QObject):
... asig = QtCore.pyqtSignal()
... def __init__(self):
... QtCore.QObject.__init__(self)
... print self.asig
...
>>> k = CX()
<bound signal asig of CX object at 0x00B91420>

Using latest stable SIP and PyQt4 with Qt 4.7.2

On Mon, Jun 27, 2011 at 3:29 PM, Giuseppe Corbelli <giuseppe.corbelli <at> copanitalia.com> wrote:
On 27/06/2011 17:23, Giuseppe Corbelli wrote:
> Hi all
>
> I have two boxes:
> Linux with PyQt-GPL 4.8.3/Qt 4.7.0/Python 2.6.6
> Windows 7 with PyQt-Commercial 4.8.4/Qt 4.7.3/ActivePython 2.6.6.18

Forgot:
sip 4.12.1 on Linux machine
sip 4.12.3 on Linux machine

--
           Giuseppe Corbelli
WASP Software Engineer, Copan Italia S.p.A
Phone: +390303666104  Fax: +390302659932
E-mail: giuseppe.corbelli <at> copanitalia.com
_______________________________________________
PyQt mailing list    PyQt <at> riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

<div>
<div>On WinXP Pro and Python 2.7.1 this is what I get:<br>
</div>
<div><br></div>
<div>&gt;&gt;&gt; class CX(QtCore.QObject):<br>...     asig = QtCore.pyqtSignal()<br>...     def __init__(self):<br>...             QtCore.QObject.__init__(self)<br>
...             print self.asig<br>...<br>&gt;&gt;&gt; k = CX()<br>&lt;bound signal asig of CX object at 0x00B91420&gt;<br>
</div>
<div><br></div>
<div>Using latest stable SIP and PyQt4 with Qt 4.7.2</div>
<br><div class="gmail_quote">
On Mon, Jun 27, 2011 at 3:29 PM, Giuseppe Corbelli <span dir="ltr">&lt;<a href="mailto:giuseppe.corbelli <at> copanitalia.com">giuseppe.corbelli <at> copanitalia.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote">
<div class="im">On 27/06/2011 17:23, Giuseppe Corbelli wrote:<br>
&gt; Hi all<br>
&gt;<br>
&gt; I have two boxes:<br>
&gt; Linux with PyQt-GPL 4.8.3/Qt 4.7.0/Python 2.6.6<br>
&gt; Windows 7 with PyQt-Commercial 4.8.4/Qt 4.7.3/ActivePython 2.6.6.18<br><br>
</div>Forgot:<br>
sip 4.12.1 on Linux machine<br>
sip 4.12.3 on Linux machine<br><div><div class="h5">
<br>
--<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Giuseppe Corbelli<br>
WASP Software Engineer, Copan Italia S.p.A<br>
Phone: <a href="tel:%2B390303666104" value="+390303666104">+390303666104</a> &nbsp;Fax: <a href="tel:%2B390302659932" value="+390302659932">+390302659932</a><br>
E-mail: <a href="mailto:giuseppe.corbelli <at> copanitalia.com">giuseppe.corbelli <at> copanitalia.com</a><br>
_______________________________________________<br>
PyQt mailing list &nbsp; &nbsp;<a href="mailto:PyQt <at> riverbankcomputing.com">PyQt <at> riverbankcomputing.com</a><br><a href="http://www.riverbankcomputing.com/mailman/listinfo/pyqt" target="_blank">http://www.riverbankcomputing.com/mailman/listinfo/pyqt</a><br>
</div></div>
</blockquote>
</div>
<br>
</div>
Jarosław Białas | 1 Jul 2011 19:00
Picon

Re: [SIP]MD5 openssl

Hello again,

In the case that somebody want to help me with that problem, I attached 
some files.
Attachment (configure.py): text/x-python, 718 bytes
Attachment (md5test.cpp): text/x-c++src, 341 bytes
Attachment (md5test.h): text/x-chdr, 69 bytes
%Module md5test

class md5test
{
%TypeHeaderCode
#include <iostream>
#include <openssl/md5.h>
#include "md5test.h"
%End

public:
    void hash();
};

%Module md5test

class md5test
{
%TypeHeaderCode
#include <iostream>
#include <openssl/md5.h>
#include "md5test.h"
%End

public:
    void hash();
};

David Boddie | 1 Jul 2011 19:57
Picon
Gravatar

Re: [SIP]MD5 openssl

On Wed Jun 29 10:38:07 BST 2011, Jarosław Białas wrote:

> Recently I tried to use my c++ library in Python using SIP.
> In SIP configuration file I added some extra libraries like QtGui,fftw3
> and ssl.
> Compilation and linking pass without any warnings or errors:
>
> g++ -c -pipe -fPIC -O2 -Wall -W -DNDEBUG -I. -I/usr/include/python2.7 -o
> sipmd5testcmodule.o sipmd5testcmodule.cpp
> g++ -c -pipe -fPIC -O2 -Wall -W -DNDEBUG -I. -I/usr/include/python2.7 -o
> sipmd5testmd5test.o sipmd5testmd5test.cpp
> g++ -c -pipe -fPIC -O2 -Wall -W -DNDEBUG -I. -I/usr/include/python2.7 -o
> md5test.o md5test.cpp
> g++ -Wl,--hash-style=gnu -Wl,--as-needed -shared
> -Wl,--version-script=md5test.exp -o md5test.so sipmd5testcmodule.o
> sipmd5testmd5test.o md5test.o -lssl
>
> But when I try to import library:
> ImportError: ./md5test.so: undefined symbol: MD5

It seems to me that your use of the MD5 function isn't resolved at run-time.
Since you're building a library, the linker doesn't care because it expects
that it will find that symbol later.

> When I compiled my code and included it in c++ all worked fine.

When you run ldd on the md5test.so file, what do you get as output? I get
this:

$ ldd md5test.so
        libssl.so.0.9.8 => /usr/lib/i686/cmov/libssl.so.0.9.8 (0xb776f000)
        libstdc++.so.6 => /usr/local/lib/libstdc++.so.6 (0xb7684000)
        libm.so.6 => /lib/tls/i686/cmov/libm.so.6 (0xb765e000)
        libgcc_s.so.1 => /usr/local/lib/libgcc_s.so.1 (0xb7640000)
        libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb74f1000)
        libcrypto.so.0.9.8 => /usr/lib/i686/cmov/libcrypto.so.0.9.8 
(0xb73af000)
        libdl.so.2 => /lib/tls/i686/cmov/libdl.so.2 (0xb73ab000)
        libz.so.1 => /usr/lib/libz.so.1 (0xb7396000)
        /lib/ld-linux.so.2 (0xb77d2000)

If the first line in your output indicates that libssl.so cannot be found
then you may need to update your build file to add a suitable library path
for that library.

David
_______________________________________________
PyQt mailing list    PyQt <at> riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Hans-Peter Jansen | 1 Jul 2011 19:57

Re: QPainter::end: Painter ended with 2 saved states

Hi Eric,

sorry for the delay.

On Tuesday 28 June 2011, 21:42:51 Eric Frederich wrote:
> Here is a reworked example.
> Do you see any potential problems with this one?
> Is the call to setText okay?

Sure, it's done from the main thread, hence in the main thread context.

> Is it okay to access the data member the way I'm doing it in
> print_data?

Hmm, you access Blah.data after your 'SLEPT' loop finished. In this 
special case, it seems save, but it reminded me on one of 
Linus' "special" phrases: "Yes, it's manly, but let's face it, so is 
bungee-jumping with the cord tied to your testicles."

Okay, might be a bit exaggerated for this case..

Anyway, you should turn your code to use new style signals/slots. Raises 
readability and greatly reduces strokes. BTW, I tend to use lambda 
expressions instead of partials, but that's more of a personal 
preference. 

Pete
Jarosław Białas | 1 Jul 2011 23:38
Picon

Re: [SIP]MD5 openssl

I accidentally send below message only to David, repostion to groups. On 01.07.2011 19:57, David Boddie wrote: > On Wed Jun 29 10:38:07 BST 2011, Jarosław Białas wrote: > >> Recently I tried to use my c++ library in Python using SIP. >> In SIP configuration file I added some extra libraries like QtGui,fftw3 >> and ssl. >> Compilation and linking pass without any warnings or errors: >> >> g++ -c -pipe -fPIC -O2 -Wall -W -DNDEBUG -I. -I/usr/include/python2.7 -o >> sipmd5testcmodule.o sipmd5testcmodule.cpp >> g++ -c -pipe -fPIC -O2 -Wall -W -DNDEBUG -I. -I/usr/include/python2.7 -o >> sipmd5testmd5test.o sipmd5testmd5test.cpp >> g++ -c -pipe -fPIC -O2 -Wall -W -DNDEBUG -I. -I/usr/include/python2.7 -o >> md5test.o md5test.cpp >> g++ -Wl,--hash-style=gnu -Wl,--as-needed -shared >> -Wl,--version-script=md5test.exp -o md5test.so sipmd5testcmodule.o >> sipmd5testmd5test.o md5test.o -lssl >> >> But when I try to import library: >> ImportError: ./md5test.so: undefined symbol: MD5 > > It seems to me that your use of the MD5 function isn't resolved at run-time. > Since you're building a library, the linker doesn't care because it expects > that it will find that symbol later. > >> When I compiled my code and included it in c++ all worked fine. > > When you run ldd on the md5test.so file, what do you get as output? I get > this: > > $ ldd md5test.so > libssl.so.0.9.8 => /usr/lib/i686/cmov/libssl.so.0.9.8 (0xb776f000) > libstdc++.so.6 => /usr/local/lib/libstdc++.so.6 (0xb7684000) > libm.so.6 => /lib/tls/i686/cmov/libm.so.6 (0xb765e000) > libgcc_s.so.1 => /usr/local/lib/libgcc_s.so.1 (0xb7640000) > libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb74f1000) > libcrypto.so.0.9.8 => /usr/lib/i686/cmov/libcrypto.so.0.9.8 > (0xb73af000) > libdl.so.2 => /lib/tls/i686/cmov/libdl.so.2 (0xb73ab000) > libz.so.1 => /usr/lib/libz.so.1 (0xb7396000) > /lib/ld-linux.so.2 (0xb77d2000) > > If the first line in your output indicates that libssl.so cannot be found > then you may need to update your build file to add a suitable library path > for that library. > > David > _______________________________________________ > PyQt mailing list PyQt <at> riverbankcomputing.com > http://www.riverbankcomputing.com/mailman/listinfo/pyqt  I have done everything like you do, but instead of that I get: $ ldd md5test.so linux-vdso.so.1 => (0x00007ffffe7cd000) libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007fa458142000) libc.so.6 => /lib/libc.so.6 (0x00007fa457de1000) libm.so.6 => /lib/libm.so.6 (0x00007fa457b5e000) /lib/ld-linux-x86-64.so.2 (0x00007fa45867b000) libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007fa457948000) When I tried: $ g++ -fPIC -shared md5test.cpp -o md5test.so -lssl $ ldd md5test.so linux-vdso.so.1 => (0x00007fffad5ff000) libssl.so.1.0.0 => /usr/lib/libssl.so.1.0.0 (0x00007ff7cc347000) libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007ff7cc03d000) libm.so.6 => /lib/libm.so.6 (0x00007ff7cbdba000) libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007ff7cbba4000) libc.so.6 => /lib/libc.so.6 (0x00007ff7cb843000) libcrypto.so.1.0.0 => /usr/lib/libcrypto.so.1.0.0 (0x00007ff7cb486000) libdl.so.2 => /lib/libdl.so.2 (0x00007ff7cb282000) libz.so.1 => /usr/lib/libz.so.1 (0x00007ff7cb06a000) /lib/ld-linux-x86-64.so.2 (0x00007ff7cc7d1000) Then I realized that libcrypto is also linked to shared library. I add crypto to configuration file and despite the fact that libssl is still missing(I really don't know why), libcrypto is present. Finally I imported md5test successfully. Thank you for helping me again.
<div>
    <span class="Apple-style-span">
      I accidentally send below message only to David, repostion to groups.
    </span>
    On 01.07.2011 19:57, David Boddie wrote:
&gt; On Wed Jun 29 10:38:07 BST 2011, Jaros&#322;aw Bia&#322;as wrote:
&gt;
&gt;&gt; Recently I tried to use my c++ library in Python using SIP.
&gt;&gt; In SIP configuration file I added some extra libraries like QtGui,fftw3
&gt;&gt; and ssl.
&gt;&gt; Compilation and linking pass without any warnings or errors:
&gt;&gt;
&gt;&gt; g++ -c -pipe -fPIC -O2 -Wall -W -DNDEBUG -I. -I/usr/include/python2.7 -o
&gt;&gt; sipmd5testcmodule.o sipmd5testcmodule.cpp
&gt;&gt; g++ -c -pipe -fPIC -O2 -Wall -W -DNDEBUG -I. -I/usr/include/python2.7 -o
&gt;&gt; sipmd5testmd5test.o sipmd5testmd5test.cpp
&gt;&gt; g++ -c -pipe -fPIC -O2 -Wall -W -DNDEBUG -I. -I/usr/include/python2.7 -o
&gt;&gt; md5test.o md5test.cpp
&gt;&gt; g++ -Wl,--hash-style=gnu -Wl,--as-needed -shared
&gt;&gt; -Wl,--version-script=md5test.exp -o md5test.so sipmd5testcmodule.o
&gt;&gt; sipmd5testmd5test.o md5test.o -lssl
&gt;&gt;
&gt;&gt; But when I try to import library:
&gt;&gt; ImportError: ./md5test.so: undefined symbol: MD5
&gt;
&gt; It seems to me that your use of the MD5 function isn't resolved at run-time.
&gt; Since you're building a library, the linker doesn't care because it expects
&gt; that it will find that symbol later.
&gt;
&gt;&gt; When I compiled my code and included it in c++ all worked fine.
&gt;
&gt; When you run ldd on the md5test.so file, what do you get as output? I get
&gt; this:
&gt;
&gt; $ ldd md5test.so
&gt;          libssl.so.0.9.8 =&gt;  /usr/lib/i686/cmov/libssl.so.0.9.8 (0xb776f000)
&gt;          libstdc++.so.6 =&gt;  /usr/local/lib/libstdc++.so.6 (0xb7684000)
&gt;          libm.so.6 =&gt;  /lib/tls/i686/cmov/libm.so.6 (0xb765e000)
&gt;          libgcc_s.so.1 =&gt;  /usr/local/lib/libgcc_s.so.1 (0xb7640000)
&gt;          libc.so.6 =&gt;  /lib/tls/i686/cmov/libc.so.6 (0xb74f1000)
&gt;          libcrypto.so.0.9.8 =&gt;  /usr/lib/i686/cmov/libcrypto.so.0.9.8
&gt; (0xb73af000)
&gt;          libdl.so.2 =&gt;  /lib/tls/i686/cmov/libdl.so.2 (0xb73ab000)
&gt;          libz.so.1 =&gt;  /usr/lib/libz.so.1 (0xb7396000)
&gt;          /lib/ld-linux.so.2 (0xb77d2000)
&gt;
&gt; If the first line in your output indicates that libssl.so cannot be found
&gt; then you may need to update your build file to add a suitable library path
&gt; for that library.
&gt;
&gt; David
&gt; _______________________________________________
&gt; PyQt mailing list    <a class="moz-txt-link-abbreviated" href="mailto:PyQt <at> riverbankcomputing.com">PyQt <at> riverbankcomputing.com</a>
&gt; <a class="moz-txt-link-freetext" href="http://www.riverbankcomputing.com/mailman/listinfo/pyqt">http://www.riverbankcomputing.com/mailman/listinfo/pyqt</a>

&nbsp;I have done everything like you do, but instead of that I get:

$ ldd md5test.so
    linux-vdso.so.1 =&gt;  (0x00007ffffe7cd000)
    libstdc++.so.6 =&gt; /usr/lib/libstdc++.so.6 (0x00007fa458142000)
    libc.so.6 =&gt; /lib/libc.so.6 (0x00007fa457de1000)
    libm.so.6 =&gt; /lib/libm.so.6 (0x00007fa457b5e000)
    /lib/ld-linux-x86-64.so.2 (0x00007fa45867b000)
    libgcc_s.so.1 =&gt; /usr/lib/libgcc_s.so.1 (0x00007fa457948000)

When I tried:

$ g++ -fPIC -shared  md5test.cpp -o md5test.so -lssl
$ ldd md5test.so
    linux-vdso.so.1 =&gt;  (0x00007fffad5ff000)
    libssl.so.1.0.0 =&gt; /usr/lib/libssl.so.1.0.0 (0x00007ff7cc347000)
    libstdc++.so.6 =&gt; /usr/lib/libstdc++.so.6 (0x00007ff7cc03d000)
    libm.so.6 =&gt; /lib/libm.so.6 (0x00007ff7cbdba000)
    libgcc_s.so.1 =&gt; /usr/lib/libgcc_s.so.1 (0x00007ff7cbba4000)
    libc.so.6 =&gt; /lib/libc.so.6 (0x00007ff7cb843000)
    libcrypto.so.1.0.0 =&gt; /usr/lib/libcrypto.so.1.0.0 (0x00007ff7cb486000)
    libdl.so.2 =&gt; /lib/libdl.so.2 (0x00007ff7cb282000)
    libz.so.1 =&gt; /usr/lib/libz.so.1 (0x00007ff7cb06a000)
    /lib/ld-linux-x86-64.so.2 (0x00007ff7cc7d1000)

Then I realized that libcrypto is also linked to shared library.
I add crypto to configuration file and despite the fact that libssl is 
still missing(I really don't know why), libcrypto is present.
Finally I imported md5test successfully.
Thank you for helping me again.

  </div>

Gmane