GNOME Bugzilla – Bug 727608
Compilation failure if qt4 doesn't have STL support
Last modified: 2014-04-07 09:47:51 UTC
During the configure phase NetworkManager checks if Qt is installed. If the detection is successful, then it passes the option --enable-qt which builds an example program located in examples/C/qt/monitor-nm-running.cpp That program uses toStdString(), which is only available when Qt is compiled with STL support. Check this: http://developer.qt.nokia.com/doc/qt-4.8/qstring.html#toStdString So, checking if Qt is installed is not enough. It also needs to check if the installed Qt has STL support. To do that, the configure scrip could do a compilation test of a simple program like this one: #include <QtCore/QtGlobal> #ifdef QT_NO_STL #error "No STL" #endif int main() {} And compile it with: g++ -I$(qmake -query QT_INSTALL_HEADERS) -c check_for_qt_stl.cpp
Created attachment 273591 [details] [review] [PATCH] don't use toStdString() in qt demo Wouldn't it be simpler just to fix the example program? I don't have QT installed. Does the attached patch fix the issue?
(In reply to comment #1) > Created an attachment (id=273591) [details] [review] > [PATCH] don't use toStdString() in qt demo > > Wouldn't it be simpler just to fix the example program? > > I don't have QT installed. Does the attached patch fix the issue? No, calling .constData() doesn't produce the same result: $ cat test.cpp #include <iostream> #include <QtCore/QString> int main() { QString my_string = "hello world"; std::cout << "with toStdString() " << my_string.toStdString() << std::endl; std::cout << "with constData() " << my_string.constData() << std::endl; } $ g++ -I$(qmake-qt4 -query QT_INSTALL_HEADERS) -lQtCore test.cpp -o test $ ./test with toStdString() hello world with constData() 0xf3d25a
If you change .toStdString() by .toUtf8().constData() works.
I pushed the commit to upstream master: http://cgit.freedesktop.org/NetworkManager/NetworkManager/commit/?id=2748bcfebff927bc2bae988d42e143e3fd68445c (actually, I accidentally pushed the wrong patch to master. That's the reason for the rush now, to fix it). I think this bug is resolved now. If there is something not working, please reopen. Thanks!!
You are welcome :)