Proxmark3 developers community

Research, development and trades concerning the powerful Proxmark3 device.

Remember; sharing is caring. Bring something back to the community.


"Learn the tools of the trade the hard way." +Fravia

You are not logged in.

#1 2013-06-26 13:59:34

holiman
Contributor
Registered: 2013-05-03
Posts: 566

Compiling with QT5 on ubuntu 13.04

I recently upgraded my distro to 13.04. This includes qt5, which causes some conflicts with qt4. The makefile on linux does this :

CXXFLAGS = $(shell pkg-config --cflags QtCore QtGui 2>/dev/null) -Wall -O4
QTLDLIBS = $(shell pkg-config --libs QtCore QtGui 2>/dev/null)
MOC = $(shell pkg-config --variable=moc_location QtCore)

When testing in the console, this is the result:

$ pkg-config --cflags QtCore QtGui
-DQT_SHARED -I/usr/include/qt4 -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui  
martin@lenovox2:~/workspace/proxmark3-scripting/client
$ pkg-config --libs QtCore QtGui
-lQtGui -lQtCore  

(Notice the reference to tq4). However, the moc resolves differently, and uses Qt5:

$ pkg-config --variable=moc_location QtCore
/usr/bin/moc
martin@lenovox2:~/workspace/proxmark3-scripting/client
$ /usr/bin/moc -v
Qt Meta Object Compiler version 67 (Qt 5.0.1)

This does not work well, since there is a version mismatch:

g++ -DQT_SHARED -I/usr/include/qt4 -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui   -Wall -O4 -c -o obj/proxguiqt.moc.o proxguiqt.moc.cpp
proxguiqt.moc.cpp:15:2: error: #error "This file was generated using the moc from 5.0.1. It"
proxguiqt.moc.cpp:16:2: error: #error "cannot be used with the include files from this version of Qt."
proxguiqt.moc.cpp:17:2: error: #error "(The moc has changed too much.)"
proxguiqt.moc.cpp:22:5: error: ‘QByteArrayData’ does not name a type
proxguiqt.moc.cpp:32:1: error: ‘QByteArrayData’ was not declared in this scope
...

There are two ways to solve this. First, you can change so qt5 is used consistently. Apparently, they have moved QApplication into the widget-namespace. But something like this makes it compile ok (some info about this at http://lists.qt-project.org/pipermail/development/2012-September/006548.html) :

CXXFLAGS = $(shell pkg-config --cflags Qt5Core Qt5Gui Qt5Widgets 2>/dev/null) -Wall -O4 -fPIC
QTLDLIBS = $(shell pkg-config --libs Qt5Core Qt5Gui Qt5Widgets 2>/dev/null)
MOC = $(shell pkg-config --variable=moc_location QtCore)

However, every time I quit the app, it exited with a segmentation fault. So instead, I reverted to use the moc from qt4:

CXXFLAGS = $(shell pkg-config --cflags QtCore QtGui 2>/dev/null) -Wall -O4
QTLDLIBS = $(shell pkg-config --libs QtCore QtGui 2>/dev/null)
MOC = /usr/lib/x86_64-linux-gnu/qt4/bin/moc

I haven't comitted this to the svn, since this is a very non-generic solution to the problem - I have hardcoded the path to the moc I want to use. If anyone has a better solution which is more generic, that'd be great.

Offline

Board footer

Powered by FluxBB