Okay... technically not my app, but the app from the Qt Mobility Quickstart example.
Building Qt Mobility Quickstart App
- Make sure to install Qt Mobility and set LD_LIBRARY_PATH environment variable to point to your Qt Mobility install/lib folder.
- Create a new Qt GUI Project. If you need help here, refer to Hello World Qt GUI App.
- Paste the following code into main.cpp :
#include <QApplication> #include <QLabel> #ifdef Q_OS_SYMBIAN #include <qsysteminfo.h> #else #include <QSystemInfo> //(1) #endif using namespace QtMobility; //(2) int main(int argc, char *argv[]) { QApplication app(argc, argv); QSystemInfo s; QLabel *label = new QLabel(QObject::tr("hello ").append(s.currentCountryCode())); label->show(); label->resize(100,30); return app.exec(); }
- Qt Mobility Quickstart tutorial tells you to add this to your project's .pro file:
CONFIG += mobility MOBILITY += systeminfo
- Build the project...
- At this point I get this error with QNetworkInterface:
g++ -c -pipe -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Trolltech/Qt-4.6.0/mkspecs/linux-g++ -I. -I/usr/local/Trolltech/Qt-4.6.0/include/QtCore -I/usr/local/Trolltech/Qt-4.6.0/include/QtGui -I/usr/local/Trolltech/Qt-4.6.0/include -I/usr/local/Trolltech/Qt-4.6.0/include/QtSystemInfo_tp -I/opt/qt-mobility-src-1.0.0-tp2/install/include -I. -o main.o main.cpp In file included from /opt/qt-mobility-src-1.0.0-tp2/install/include/QSystemInfo:1, from main.cpp:7: /opt/qt-mobility-src-1.0.0-tp2/install/include/qsysteminfo.h:50:29: error: QNetworkInterface: No such file or directory In file included from /opt/qt-mobility-src-1.0.0-tp2/install/include/QSystemInfo:1, from main.cpp:7: /opt/qt-mobility-src-1.0.0-tp2/install/include/qsysteminfo.h:183: error: ‘QNetworkInterface’ does not name a type make: Leaving directory `/home/ceefour/Sandbox/quickstart-mobility' make: *** [main.o] Error 1 Exited with code 2. Error while building project quickstart-mobility When executing build step 'Make'
- Seems like Qt Mobility tutorial writer forgot to add dependency to network module that provides QNetworkInterface. Add the following to your .pro file:
QT += network
- Run the project.
Qt Mobility Quickstart in Action
The Quickstart project displays the following very simple dialog:It looks very simple and harmless, yet it's so powerful.
Why powerful? Because you can build this very same app for all platforms supported by Qt Mobility, and it'll work just as well... that is, displaying the current locale.
Don't believe me? Build and run exactly the same source code on Windows (no changes whatsoever) and voila!
For those who have programmed in Java, this is similar to Java Mobile Edition (J2ME). The primary benefits are:
- It's natively compiled. Therefore, the app runs optimally in all devices and platforms.
- It uses the same underlying library: Qt library and Qt GUI widget toolkit. Unlike Java where you'll use Swing or SWT on the desktop, and Java ME widgets on the client. In all Qt Mobility platforms, you use Qt GUI.
- No need for a Java Runtime Engine (JRE). Most Qt applications are dynamically linked with Qt shared libraries for size and other reasons. You can also statically link Qt libraries for platforms that doesn't have Qt preinstalled. In that regard, Qt app (therefore, Qt Mobility app) is indistinguishable from that platform's native apps.
About LD_LIBRARY_PATH
If you don't set LD_LIBRARY_PATH properly, your app still builds successfullly. However, you will encounter the following error when running the app:
/home/ceefour/Sandbox/quickstart-mobility/quickstart-mobility: error while loading shared libraries: libQtSystemInfo_tp.so.1: cannot open shared object file: No such file or directory
Error messages on Windows are slightly different, but same meaning: it cannot find the required binary library files.
c:/qt/2009.05/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../../mingw32/bin/ld.exe: cannot find -lQtSystemInfo_tpd collect2: ld returned 1 exit status
To resolve this problem, either add the following to $HOME/.bashrc and restart your computer:
# Qt Mobility export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/qt-mobility-src-1.0.0-tp2/install/lib
or, set LD_LIBRARY_PATH from your project settings (not recommended):
- Switch to Projects mode (Ctrl+4).
- Choose your project.
- Under Build Environment, click Show Details.
- Select LD_LIBRARY_PATH, click Edit, and append (separated by colon ":") your Qt Mobility path there, e.g. :/opt/qt-mobility-src-1.0.0-tp2/install/lib
Hi Hendy,
ReplyDeleteI followed your example to create the Qt Mobility quickstart app but I cant get the application to run. I keep getting the "error while loading shared libraries: libQtSystemInfo.so.1: cannot open shared object file: No such file or directory" error even though I have set the LD_LIBRARY_PATH. Are you able to help me get this going?
I am using Qt Creator which come with the Nokia Qt SDK (which apparently includes Qt Mobility) on Windows 7. I have set the LD_LIBRARY_PATH to C:\NokiaQtSDK\Maemo\4.6.2\sysroots\fremantle-arm-sysroot-1014-slim\usr\lib.
Any help would be appreciated.
Regards,
Mohannad
Mohannad:
ReplyDeleteYou seem trying to build a Qt app for Windows using the Qt Mobility for Maemo library, that won't work.
To install Qt Mobility libraries/SDK on Windows, follow this article: http://qt-mobility.blogspot.com/2010/01/installing-qt-mobility-on-windows-7.html
Hi hendy,
ReplyDeleteI've installed
1.qt-sdk-win-opensource-2010.04 intoC:\Qt\2010.04
2.Nokia Symbian sdk ^3 into C:\Nokia\devices
\Nokia_Symbian3_SDK_v0.8
3.Carbide 2.3 into C:\Program Files\Nokia
\Carbide.c++ v2.3
4.Active perl into C:\Perl also Java
5.Qt mobility1.1.0 unzipped into C:\Qtmobility
\qt-mobility-opensource-src-1.1.0-tp
In Qt command promt i typed "configure -prefix c:\Qtmobility\desination" then "mingw32-make",then "mingw32-make install"
It created 3 folders "bin,include,lib,plugin" inside C:\qt\mobility\destination. and also some library & include files into C:\Qtmobility
\qt-mobility-opensource-src-1.1.0-tp
now i want to use the mobility classes..
in Qt creator build settings, i set "LD_LIBRARY_PATH" to "C:\Qtmobility\destination\lib"
When i tried with the above example it shows following error..
QSystemInfo:No such file
QtMobility: is not a namespace
QSystemInfo:was not declared in the scope.
Regards
Debasish Sahu
Center for Artificial Intelligence & robotics,INDIA
Thanks for sharing nice information about Qt mobility quick start applications. Mobile Application Development for iPhone development and Android Mobile Application Development. Awesome post.
ReplyDeletedoes anyone have any advice on how to network handheld devices together off-line? Any advice on what platforms to use?
ReplyDeleteWhat are the applications of differential mobility spectrometer?
ReplyDeleteNeed help with programming a iphone app?
ReplyDeleteWhat are the applications of differential mobility spectrometer?
ReplyDeleteI have recently bought a book about how to make a app and the first app that I have looked at is "QuickStart". Now my problem is I wrote everything exactly like it said in the book. Everything works fine but when I run build on my app it says Method definition not in @implementation context.
ReplyDeleteI dont know why it says that but for some reason it wont let me run the app on the iPhone/iTouch simulator. Some please help me!!!!!