Qub problems

UPDATE (17/10/2012): the compilation problems described below have been solved, and now qttools is
compiled through the 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 install". Thanks for the hard work by Martin, it helped a lot
finding what was wrong!


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 module from Qub/CTools. There were several issues to sort out before I got there.


First: qttools from Qub/CTools are not compiled by default. Qub’s 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.


The real issue was getting qttools compiled. After descending to Qub/CTools/qttools and running custom (python && 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;

+#undef Int
+#undef UInt
+#undef Bool
 class Q_EXPORT QVariant

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 =>  (0xb76ff000) => /usr/lib/ (0xb6f58000) => /usr/lib/i386-linux-gnu/ (0xb6e24000) => /lib/i386-linux-gnu/ (0xb6e08000) => /usr/lib/i386-linux-gnu/ (0xb6d23000) => /lib/i386-linux-gnu/ (0xb6d05000) => /lib/i386-linux-gnu/ (0xb6b5b000) => /usr/lib/i386-linux-gnu/ (0xb6b27000) => /usr/lib/i386-linux-gnu/ (0xb6b0d000) => /usr/lib/i386-linux-gnu/ (0xb6ab6000) => /lib/i386-linux-gnu/ (0xb6a8c000) => /lib/i386-linux-gnu/ (0xb6a76000) => /usr/lib/i386-linux-gnu/ (0xb6a66000) => /usr/lib/i386-linux-gnu/ (0xb6a5b000) => /usr/lib/i386-linux-gnu/ (0xb6a52000) => /usr/lib/i386-linux-gnu/ (0xb6a47000) => /usr/lib/i386-linux-gnu/ (0xb6a43000) => /usr/lib/i386-linux-gnu/ (0xb6a2d000) => /usr/lib/i386-linux-gnu/ (0xb6992000) => /usr/lib/i386-linux-gnu/ (0xb6980000) => /usr/lib/i386-linux-gnu/ (0xb6977000) => /usr/lib/i386-linux-gnu/ (0xb695d000) => /lib/i386-linux-gnu/ (0xb6958000) => /lib/i386-linux-gnu/ (0xb692b000) => /usr/lib/i386-linux-gnu/ (0xb690a000)
    /lib/ (0xb7700000) => /lib/i386-linux-gnu/ (0xb68e0000) => /usr/lib/i386-linux-gnu/ (0xb6884000) => /usr/lib/i386-linux-gnu/ (0xb6880000) => /usr/lib/i386-linux-gnu/ (0xb6879000) => /lib/i386-linux-gnu/ (0xb6873000) => /usr/lib/i386-linux-gnu/ (0xb686c000)
undefined symbol: PyCapsule_Type    (./
undefined symbol: _Py_NoneStruct    (./
undefined symbol: PyDict_GetItemString    (./
undefined symbol: PyModule_GetDict    (./
undefined symbol: Py_InitModule4    (./
undefined symbol: PyImport_ImportModule    (./
undefined symbol: PyCapsule_GetPointer    (./
undefined symbol: PyLong_FromUnsignedLong    (./
undefined symbol: PyInt_FromLong    (./
undefined symbol: PyBool_FromLong    (./

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


I would like to acknowledge great help from Frederick Picca in sorting out the qttools problem.