Qub problems » History » Version 3

Version 2 (Savko, Martin, 16/10/2012 12:00 PM) → Version 3/4 (Savko, Martin, 16/10/2012 01:23 PM)

h1. Qub problems

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

h2. Setup

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.

h2. qttools

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 [[ qttools_compile_error | full output]] ).

To make long story short, 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, working 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.

h2. 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

h2. Acknowledgement

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