Hi Guys,
Sorry for the long post, I think the question is relatively simple, but I feel the need to explain the situation I got myself into, however you can probably jump straight to the “Questions” section at the end :) …
I have been using Qt SDK 5.0.2 on Windows and Linux with much success :)
However, I am now expanding my operation and trying to make a sound build environment and a repeatable process to make it. I have almost got there but I have a couple of little niggles left.
Problem Description
Using virtual box to keep testing my installations I am creating systems with Ubuntu 12.04 + all updates. This was my process:
1. install QtCreator from the Ubuntu software centre (this was a mistake I think)
2. Uninstall Qt Creator from the Ubuntu software centre.
3. Download Qt SDK 5.0.2 from “qt-project.org/downloads”, then cd to the download directory and do:
sudo chmod +x qt-linux-opensource-5.0.2-x86-offline.run
sudo ./qt-linux-opensource-5.0.2-x86-offline.run
Other then installing Qt Creator and un-installing it, everything is the same as my working Linux version (on real PC, i.e. non-Virtual box)
But I get the following issue:
main.cpp:60:45: error: 'QMessageLogContext' does not name a type
main.cpp:60:65: error: ISO C++ forbids declaration of 'context' with no type [-fpermissive]
main.cpp: In function 'void qDebugMsgHandler(QtMsgType, const int&, const QString&)':
Here is my code (which works very well on my Qt 5.0.2 on windows and my other linux installation:
// Message handler for qDebug(), qWarning(), qCritical(), qFatal().
// Note: For qDebug() there are no automatic end-of-lines for maximum
// flexibility this means that you need to put a "\n" or << endl; at
// the end of your message.
void qDebugMsgHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
{
QByteArray localMsg = msg.toLocal8Bit();
switch (type) {
case QtDebugMsg:
myprintf(OUT_ALL, "%s", localMsg.constData());
break;
case QtWarningMsg:
myprintf(OUT_ALL, "\nWarning: %s \t%s (line %u) in %s\n\n", localMsg.constData(), context.file, context.line, context.function);
break;
case QtCriticalMsg:
myprintf(OUT_ALL, "\nCritical: %s \t%s (line %u) in %s\n\n", localMsg.constData(), context.file, context.line, context.function);
break;
case QtFatalMsg:
myprintf(OUT_ALL, "\nFatal: %s \t%s (line %u) in %s\n\n", localMsg.constData(), context.file, context.line, context.function);
abort();
}
}
Questions
1. QMessageLogContext is a Qt 5 addition. It looks like I don’t have that library. When I add the line ‘#include <QMessageLogContext>’, the tool tip even says “can’t find file”. So how do I install this library?
2. Also my include paths during the build are suspect, for example:
g++ -c -pipe -Wall -O2 -Wall -W -D_REENTRANT -DQT_WEBKIT -DQT_NO_DEBUG -DQT_XML_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtNetwork -I/usr/include/qt4/QtXml -I/usr/include/qt4 -Icommsnet -Icommsnet/device -Icommsnet/vocoder -Iconfig -Iif -Irpe -Irtp -ItacChat -Iutils -I../_out -o ../_out/main.o main.cpp
You can see there are not Qt5 paths whereas on my other linux build there are many more paths like “usr/share/Qt5.0.2/5.0.2/gcc/include/QtCore, etc…. does this mean that I don’t have Qt 5 properly installed?
3. What can I do about this to update it?
I have the feeling when I installed Qt Creator on its own I screwed up :( , but I am not sure if that is the issue or not
EDIT: forgot to add: When I remove this code (i.e. comment it out) my project builds and runs great :). I figure that most of the stuff I use is pre Qt5 stuff .. so at least I have some sort of working version of Qt :o
↧