Qub problems¶
UPDATE (17/10/2012): the compilation problems described below have been solved, and now qttools is
compiled through the setup.py script. See git log for details. Both v2 and master branches have
been updated. Do "git pull" in mxCuBE directory then "git submodule update" and go to libs/Qub,
in order to start "python setup.py install". Thanks for the hard work by Martin, it helped a lot
finding what was wrong!
Motivation¶
I’ve been working on centering mxCuBE application recently. I run into several problems while trying to get there. Resolved them :-) and I would like to share the experience on this forum.
The systems I’ve been working on are Ubuntu 10.04 64bit and Ubuntu 12.04 32 bit.
To make the MD2 camera working I needed to compile qttools.so module from Qub/CTools. There were several issues to sort out before I got there.
Setup¶
First: qttools from Qub/CTools are not compiled by default. Qub’s setup.py does not refer to this submodule (and two other submodules: opencv and qwttools). This is not fatal but would be more comfortable to have it there.
qttools¶
The real issue was getting qttools compiled. After descending to Qub/CTools/qttools and running custom configure.py (python configure.py && make) I was getting bizarre error messages. This is the critical part of the output:
... g++ -c -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -O1 -fPIC -Wall -W -D_REENTRANT -DNDEBUG -DQT_NO_DEBUG -DQT_THREAD_SUPPORT -I. -I/usr/include/python2.7 -I/usr/share/qt3/mkspecs/default -I/usr/share/qt3/include -I/usr/X11R6/include -o sipqttoolsQtXEmbedContainer.o sipqttoolsQtXEmbedContainer.cpp In file included from /usr/share/sip/qt/qt/qvariant.sip:201:0: /usr/share/qt3/include/qvariant.h:111:2: error: expected identifier before ‘int’ /usr/share/qt3/include/qvariant.h:111:2: error: expected ‘}’ before ‘int’ /usr/share/qt3/include/qvariant.h:111:6: error: expected unqualified-id before ‘,’ token ...
(see full output ).
To make long story short, it was possible to get around the problem making changes to qvariant.h file from qt3 distribution (/usr/include/qt3/qvariant.h on my system). The change that finally made thing work, was to undefine three variables: Int, UInt and Bool. This is the required change in the form of patch
--- qvariant.h 2012-10-16 11:13:15.341595088 +0200 +++ qvariant.h_working 2012-10-16 11:15:19.557591418 +0200 @@ -82,6 +82,10 @@ template <class Key, class T> class QMapConstIterator; #endif +#undef Int +#undef UInt +#undef Bool + class Q_EXPORT QVariant { public:
after this change the compilation started to succeed.
linking to python¶
Although the library now was compiled, there was still a minor issue with linking to python libraries:
$ ldd -r qttools.so linux-gate.so.1 => (0xb76ff000) libqt-mt.so.3 => /usr/lib/libqt-mt.so.3 (0xb6f58000) libX11.so.6 => /usr/lib/i386-linux-gnu/libX11.so.6 (0xb6e24000) libpthread.so.0 => /lib/i386-linux-gnu/libpthread.so.0 (0xb6e08000) libstdc++.so.6 => /usr/lib/i386-linux-gnu/libstdc++.so.6 (0xb6d23000) libgcc_s.so.1 => /lib/i386-linux-gnu/libgcc_s.so.1 (0xb6d05000) libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xb6b5b000) libfontconfig.so.1 => /usr/lib/i386-linux-gnu/libfontconfig.so.1 (0xb6b27000) libaudio.so.2 => /usr/lib/i386-linux-gnu/libaudio.so.2 (0xb6b0d000) libjpeg.so.8 => /usr/lib/i386-linux-gnu/libjpeg.so.8 (0xb6ab6000) libpng12.so.0 => /lib/i386-linux-gnu/libpng12.so.0 (0xb6a8c000) libz.so.1 => /lib/i386-linux-gnu/libz.so.1 (0xb6a76000) libXi.so.6 => /usr/lib/i386-linux-gnu/libXi.so.6 (0xb6a66000) libXrender.so.1 => /usr/lib/i386-linux-gnu/libXrender.so.1 (0xb6a5b000) libXrandr.so.2 => /usr/lib/i386-linux-gnu/libXrandr.so.2 (0xb6a52000) libXcursor.so.1 => /usr/lib/i386-linux-gnu/libXcursor.so.1 (0xb6a47000) libXinerama.so.1 => /usr/lib/i386-linux-gnu/libXinerama.so.1 (0xb6a43000) libXft.so.2 => /usr/lib/i386-linux-gnu/libXft.so.2 (0xb6a2d000) libfreetype.so.6 => /usr/lib/i386-linux-gnu/libfreetype.so.6 (0xb6992000) libXext.so.6 => /usr/lib/i386-linux-gnu/libXext.so.6 (0xb6980000) libSM.so.6 => /usr/lib/i386-linux-gnu/libSM.so.6 (0xb6977000) libICE.so.6 => /usr/lib/i386-linux-gnu/libICE.so.6 (0xb695d000) libdl.so.2 => /lib/i386-linux-gnu/libdl.so.2 (0xb6958000) libm.so.6 => /lib/i386-linux-gnu/libm.so.6 (0xb692b000) libxcb.so.1 => /usr/lib/i386-linux-gnu/libxcb.so.1 (0xb690a000) /lib/ld-linux.so.2 (0xb7700000) libexpat.so.1 => /lib/i386-linux-gnu/libexpat.so.1 (0xb68e0000) libXt.so.6 => /usr/lib/i386-linux-gnu/libXt.so.6 (0xb6884000) libXau.so.6 => /usr/lib/i386-linux-gnu/libXau.so.6 (0xb6880000) libXfixes.so.3 => /usr/lib/i386-linux-gnu/libXfixes.so.3 (0xb6879000) libuuid.so.1 => /lib/i386-linux-gnu/libuuid.so.1 (0xb6873000) libXdmcp.so.6 => /usr/lib/i386-linux-gnu/libXdmcp.so.6 (0xb686c000) undefined symbol: PyCapsule_Type (./qttools.so) undefined symbol: _Py_NoneStruct (./qttools.so) undefined symbol: PyDict_GetItemString (./qttools.so) undefined symbol: PyModule_GetDict (./qttools.so) undefined symbol: Py_InitModule4 (./qttools.so) undefined symbol: PyImport_ImportModule (./qttools.so) undefined symbol: PyCapsule_GetPointer (./qttools.so) undefined symbol: PyLong_FromUnsignedLong (./qttools.so) undefined symbol: PyInt_FromLong (./qttools.so) undefined symbol: PyBool_FromLong (./qttools.so)
To get around this problem I edited Makefile and added -lpython2.7 to LIBS variable. Here is the workaround in the form of a patch
--- Makefile 2012-10-16 11:24:25.805575278 +0200 +++ Makefile_working 2012-10-16 11:24:16.693575546 +0200 @@ -9,7 +9,7 @@ CFLAGS = -pipe -g -fPIC -O2 -Wall -W -D_REENTRANT CXXFLAGS = -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -O1 -fPIC -Wall -W -D_REENTRANT LFLAGS = -shared -Wl,--version-script=qttools.exp -LIBS = -L/usr/share/qt3/lib -L/usr/X11R6/lib -lqt-mt -lXext -lX11 -lm -lpthread +LIBS = -L/usr/share/qt3/lib -L/usr/X11R6/lib -lqt-mt -lXext -lX11 -lm -lpthread -lpython2.7 MOC = /usr/share/qt3/bin/moc .SUFFIXES: .c .o .cpp .cc .cxx .C
Acknowledgement¶
I would like to acknowledge great help from Frederick Picca in sorting out the qttools problem.