Re: [PyQt] QDataStream.writeUInt8 and writeInt8 unfriendly
Hi, 2012/5/26 Mickaël THOMAS micka...@gmail.com: Hi, I wanted to point out a very odd behavior (which is not that odd actually, but still...) The documentation says that QDataStream.writeUInt8 and QDataStream.writeInt8 should be passed a str rather than an int, which looks strange to me. http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qdatastream.html#writeInt8 So to write 0x80, you need to write the following in Python2 : datastream.writeInt8(chr(0x80)) And worse in Python3 : datastream.writeInt8(bytes([0x80])) I definitely think that quint8 should be converted to/from an int rather than a char. Type quint8 is an unsigned byte so I think that char is better solution. http://qt-project.org/doc/qt-4.8/qdatastream.html#operator-lt-lt-3 What's your thoughts on this? Regards, Mickael ___ PyQt mailing list PyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt Regards, Jarek ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] QDataStream.writeUInt8 and writeInt8 unfriendly
Hi, 2012/5/26 Mickaël THOMAS micka...@gmail.com: Type quint8 is an unsigned byte so I think that char is better solution. http://qt-project.org/doc/qt-4.8/qdatastream.html#operator-lt-lt-3 What do you mean by char is a better solution ? Precision and range of a variable is the same. q(u)int8 is supposed to represent an 8-bit (un)signed number, and the documentation says unsigned byte too, it's not meant to represent a char. Ok, so what is the difference between 8-bit unsigned int and 8-bit unsigned char? The problem is that quint8 is typedef unsigned char which leads SIP to convert it to a python bytes/str because python chars are one-long strings. unsigned char could be also treated like one-long string. SIP should be modified so that unsigned char is represented as a python integer (signed char should be still converted to bytes) Why? I mean why usnigned char - int is good but char - int is bad? ___ PyQt mailing list PyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt What about bigger numbers? How to represent 256? This method (QDataStream.writeUInt8) writes quint8 so what it should do: write 0x01 and 0x00, 0x00 and 0x01, just 0x00 or just 0x01? I think there is reason why in Qt you can not pass quint16 or something with bigger range to QDataStream.writeUInt8. Regards, Jarek ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Problem with passing QString
Hi, I have a library in C++ which use opencv-2.3.1. There is a function that open image using path to file (I am using QString because it is easier than converting to char*). Then I use some functions to manipulate image. Finally I want to show image in GUI, so I implemented function which convert IplImage* to QImage (again, I think it is the easiest way for me). Everything worked fine, until I tried to build and run this project under Debian. When I try to call constructor with path to an image I get following error: python: /build/buildd-sip4_4.13.2-1-amd64-oTGNAQ/sip4-4.13.2/siplib/siplib.c:7915: sip_api_can_convert_to_type: Assertion `(((td)-td_flags 0x0007) == 0x) || (((td)-td_flags 0x0007) == 0x0002)' failed. Then I cut off all functions except constructor: my_class(QString), which is empty. Problem still occures. On 1st machine (Arch Linux x86_64) I have: PyQt-4.9.1-1 Qt-4.8.0-5 SIP-4.13.2-1 On 2nd (Debian x86_64): PyQt-4.9.1-1 Qt-4.7.4-2 SIP-4.13.2-1 Is this a bug or I should rather convert QString to char* and IplImage to ... something? -- Jarek ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Problem with passing QString
I found out what the problem was. In configure.py I have: # Run SIP to generate the code. os.system( .join([config.sip_bin, -c, ., -I/usr/share/sip -I/usr/include/QtGui/ -I/usr/include/QtCore/ -t WS_X11 -t Qt_4_6_0 , -b, I changed Qt_4_6_0 to Qt_4_7_4 and now it works. Thanks for help and have a nice day:) -- Jarek On Fri, 2 Mar 2012 13:59:30 +0100, Jarosław Białas jarekbialas.bi...@gmail.com wrote: Hi, I have a library in C++ which use opencv-2.3.1. There is a function that open image using path to file (I am using QString because it is easier than converting to char*). Then I use some functions to manipulate image. Finally I want to show image in GUI, so I implemented function which convert IplImage* to QImage (again, I think it is the easiest way for me). Everything worked fine, until I tried to build and run this project under Debian. When I try to call constructor with path to an image I get following error: python: /build/buildd-sip4_4.13.2-1-amd64-oTGNAQ/sip4-4.13.2/siplib/siplib.c:7915: sip_api_can_convert_to_type: Assertion `(((td)-td_flags 0x0007) == 0x) || (((td)-td_flags 0x0007) == 0x0002)' failed. Then I cut off all functions except constructor: my_class(QString), which is empty. Problem still occures. On 1st machine (Arch Linux x86_64) I have: PyQt-4.9.1-1 Qt-4.8.0-5 SIP-4.13.2-1 On 2nd (Debian x86_64): PyQt-4.9.1-1 Qt-4.7.4-2 SIP-4.13.2-1 Is this a bug or I should rather convert QString to char* and IplImage to ... something? Can you provide a short script that demonstrates the problem? Phil ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] [SIP]MD5 openssl
Hello again, In the case that somebody want to help me with that problem, I attached some files. import os import sipconfig # The name of the SIP build file generated by SIP and used by the build # system. build_file = md5test.sbf # Get the SIP configuration information. config = sipconfig.Configuration() # Run SIP to generate the code. os.system( .join([config.sip_bin, -c, ., -b, build_file, md5test.sip])) # Create the Makefile. makefile = sipconfig.SIPModuleMakefile(config, build_file) # 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.extra_libs = [ssl] makefile._build['objects'] += md5test.o # Generate the Makefile itself. makefile.generate() #include openssl/md5.h #include md5test.h void md5test::hash() { unsigned char* hash; unsigned char* md; unsigned char* d; unsigned long n = 1; d = new unsigned char(1); *d = 123; hash = new unsigned char(16); md = new unsigned char(16); hash = MD5(d,n,md); } #include openssl/md5.h class md5test { public: void hash(); }; %Module md5test class md5test { %TypeHeaderCode #include iostream #include openssl/md5.h #include md5test.h %End public: void hash(); }; ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] [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 (0xb764) 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 listPyQt@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 = (0x7e7cd000) libstdc++.so.6 = /usr/lib/libstdc++.so.6 (0x7fa458142000) libc.so.6 = /lib/libc.so.6 (0x7fa457de1000) libm.so.6 = /lib/libm.so.6 (0x7fa457b5e000) /lib/ld-linux-x86-64.so.2 (0x7fa45867b000) libgcc_s.so.1 = /usr/lib/libgcc_s.so.1 (0x7fa457948000) When I tried: $ g++ -fPIC -shared md5test.cpp -o md5test.so -lssl $ ldd md5test.so linux-vdso.so.1 = (0x7fffad5ff000) libssl.so.1.0.0 = /usr/lib/libssl.so.1.0.0 (0x7ff7cc347000) libstdc++.so.6 = /usr/lib/libstdc++.so.6 (0x7ff7cc03d000) libm.so.6 = /lib/libm.so.6 (0x7ff7cbdba000) libgcc_s.so.1 = /usr/lib/libgcc_s.so.1 (0x7ff7cbba4000) libc.so.6 = /lib/libc.so.6 (0x7ff7cb843000) libcrypto.so.1.0.0 = /usr/lib/libcrypto.so.1.0.0 (0x7ff7cb486000) libdl.so.2 = /lib/libdl.so.2 (0x7ff7cb282000) libz.so.1 = /usr/lib/libz.so.1 (0x7ff7cb06a000) /lib/ld-linux-x86-64.so.2 (0x7ff7cc7d1000) 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. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] [SIP]MD5 openssl
Hello 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 When I compiled my code and included it in c++ all worked fine. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Passing image using SIP
On 21.06.2011 20:02, David Boddie wrote: On Mon Jun 20 23:46:27 BST 2011, Jarosław Białas wrote: I wanted to create code fragment that will pass an object containg image or pointer to this object from Python to C++ function. I tried to create function: void loadImage(QImage* image); Then I created sip file, and after compiling and linking everything looks fine until I tried to import shared library in python: ImportError: ./test.so: undefined symbol: _ZTI6QImage It looks like QtGui wasn't linked in when your shared library was created. How was the linker run? What command line options and arguments were passed to it? David ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt You were absolutely right. QtGui wasn't linked. But SIP still throw an error - sip: Q_PID is undefined. So i add SIP platform tag -t WS_X11. It wasn't working too - sip: QFileIconProvider is undefined, but after extra modification: $ /usr/bin/sip -c . -I/usr/share/sip -t WS_X11 -t Qt_4_7_2 -b hello.sbf hello.sip $ g++ -c -pipe -fPIC -O2 -Wall -W -DNDEBUG -I. -I/usr/include/python2.7 -I/usr/include/QtGui -I/usr/include/QtCore -o siphellocmodule.o siphellocmodule.cpp $ g++ -c -pipe -fPIC -O2 -Wall -W -DNDEBUG -I. -I/usr/include/python2.7 -I/usr/include/QtGui -I/usr/include/QtCore -o siphellohello.o siphellohello.cpp $ g++ -Wl,--hash-style=gnu -Wl,--as-needed -shared -Wl,--version-script=hello.exp -o hello.so siphellocmodule.o siphellohello.o I've got: undefined symbol: _ZN5hello9loadImageEP6QImage.I found out that I've only declared loadImage. So after all it works fine. Thank you for help. ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Passing image using SIP
Hello, I wanted to create code fragment that will pass an object containg image or pointer to this object from Python to C++ function. I tried to create function: void loadImage(QImage* image); Then I created sip file, and after compiling and linking everything looks fine until I tried to import shared library in python: ImportError: ./test.so: undefined symbol: _ZTI6QImage I am open to any suggestion how to solve that problem. Jaroslaw ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt