Sunday, January 31, 2010

Twitter API client library for C++ and Qt framework

QTwitterClient is an API client library for the ubiquitous Twitter microblogging service written in C++ and using the Qt framework.

QTwitterClient is cross-platform and works on all platforms supported by Qt such as Windows, Linux, and Mac OS X, even mobile platforms like Symbian and Maemo.

Usage is very simple:
QTwitterClient *twitter = new QTwitterClient(this);
twitter->setLogin(login);
twitter->setPassword(password);

twitter->tweet("I feel really good today!");
QTwitterClient is free/open source software and licensed under LGPL 2.1 or later.

Check out QTwitterClient project page to get the source code. I will appreciate any feedback you have.

Update: Moved QTwitterClient project to Gitorious.

Pastebin API client library for C++ and Qt framework

During my pursuit of Qt Mobility Contest, I created several utility class libraries. The first is QPastebinClient, which as its name suggests, is an API client library for the popular Pastebin service written in C++ and using the Qt framework.

QPastebinClient is cross-platform and works on all platforms supported by Qt, even mobile platforms like Symbian and Maemo. Usage is very simple:
QPastebinClient *pastebin = new QPastebinClient(this);

connect(pastebin, SIGNAL(finished(QString)), this, SLOT(setPastebinUrl(QString)));
connect(pastebin, SIGNAL(failed(QString)), this, SLOT(showError(QString)));

pastebin->paste("Some worthy code");

QPastebinClient is free/open source software and licensed under LGPL 2.1 or later.

Check out QPastebinClient project page to get the sources. I will appreciate any feedback you have.

Update: Moved repository to Gitorious.

Friday, January 29, 2010

Troubleshooting Qt Mobility Messaging for Symbian

My issue is compiling a Qt Mobility Messaging app for the WINSCW is not working. Qt Contacts work fine.

It seems to complain about two header files (only): qmessageglobal.h and qmessagedatacomparator.h

Other Qt Mobility headers are properly in C:\S60\devices\S60_3rd_FP2_SDK_v1.1\epoc32\include

Error messages:

make -r -f "\S60\devices\S60_3rd_FP2_SDK_v1.1\EPOC32\BUILD\Users\ceefour\Documents\qtcontest\message-merge\WINSCW.make" MAKEFILE VERBOSE=-s
WARNING: Can't find following headers in System Include Path
<qmessageglobal.h> <qmessageglobal.h> <qmessageglobal.h> <qmessageglobal.h> <qmessageglobal.h> <qmessageglobal.h> <qmessageglobal.h> <qmessageglobal.h> <qmessageglobal.h> <qmessageglobal.h> <qmessagedatacomparator.h> <qmessageglobal.h> <qmessagedatacomparator.h> <qmessageglobal.h> <qmessagedatacomparator.h> <qmessageglobal.h> <qmessageglobal.h> <qmessageglobal.h> <qmessageglobal.h> <qmessageglobal.h>
(Sys Inc Paths "\Qt\4.6.1-symbian\include\QtCore\" "\Qt\4.6.1-symbian\include\QtCore\tmp\" "\Qt\4.6.1-symbian\include\QtGui\" "\Qt\4.6.1-symbian\include\QtGui\tmp\" "\Qt\4.6.1-symbian\include\" "\Qt\4.6.1-symbian\include\tmp\" "\Users\ceefour\Documents\qtcontest\message-merge\" "\Users\ceefour\Documents\qtcontest\message-merge\tmp\" "\Qt\4.6.1-symbian\mkspecs\common\symbian\" "\Qt\4.6.1-symbian\mkspecs\common\symbian\tmp\" "\S60\devices\S60_3rd_FP2_SDK_v1.1\epoc32\include\" "\S60\devices\S60_3rd_FP2_SDK_v1.1\epoc32\include\stdapis\" "\S60\devices\S60_3rd_FP2_SDK_v1.1\epoc32\include\stdapis\sys\" "\S60\devices\S60_3rd_FP2_SDK_v1.1\epoc32\include\stdapis\stlport\" "\S60\devices\S60_3rd_FP2_SDK_v1.1\epoc32\include\variant")
Dependency list for "\Users\ceefour\Documents\qtcontest\message-merge\mainwizard.cpp" may be incomplete


Basically the errors boil down to :

the file 'qmessageglobal.h' cannot be opened

Solution

Make sure you've already added to the .pro file :

CONFIG += mobility
MOBILITY += messaging

You need to #include <qtmessaging.h> instead of individual qmessage* header files.

Then if it complains:

WARNING: Can't find following headers in System Include Path
<qtmessaging.h>
qtmessaging.h: No such file or directory

This means you have not configured Qt Mobility Messaging properly. (copying headers happened in "configure" stage, not "make")

Redo the configure, and check that you have qtmessaging.h in C:\S60\devices\S60_3rd_FP2_SDK_v1.1\epoc32\include

If it still doesn't show up, like in my case, there's a hack/workaround. Copy the following files manually from C:\QtMobility\src\messaging to C:\S60\devices\S60_3rd_FP2_SDK_v1.1\epoc32\include :
  • qtmessaging.h
  • qmessageglobal.h
  • qmessagedatacomparator.h
Assuming Qt Mobility Messaging was built successfully, at least in my case, my Qt Mobility Messaging app works fine.

Thursday, January 28, 2010

Qt Mobility for Symbian Problems & Solutions

This is mixed log of my troubleshooting attempts while developing using Qt Mobility for Symbian.
  1. Ensure WINSCW for Command Line
  2. Install Qt For Symbian
  3. Install Qt Mobility for Symbian
  4. Qt Mobility libraries:
  5. In C:\QtMobility\symbian\install_to_sdk\Qt_Mobility_tech_preview_libraries.zip
  6. Extract to C:\Symbian\9.4\S60_5th_Edition_SDK_v1.0_2
  7. Qt Mobility includes:
  8. Launch Qt for Symbian Command Prompt
  9. Make sure Perl is still in path (perl -v)

This seems wrong: "Rather than building the libraries it is also possible to deploy a prebuilt set of libraries. Under the c:\QtMobility\%DISTNAME%\symbian directory there contains Mobility_tech_preview_libraries.zip. Extract this into the SDK root directory to add the necessary libraries. If you have multiple SDKs then repeat this step for each of them."
because it only installs the binary lib files but not the header files, so we still need to at least "configure" Qt Mobility.
That should create "qcontact.h" etc. on C:\S60\devices\S60_3rd_FP2_SDK_v1.1\epoc32\include
"make" is not needed
Rebuild debug helper -- masih error
How to Build & Run:
Build configuration: using Symbian, compiler: WINSCW
Run configuration: Symbian emulator

What is WINSCW ?
WINSCW is Symbian emulator. The WINSCW compiler builds Symbian programs that can be run or debugged on the S60 Emulator.
Symbian Emulator only accepts WINSCW built programs, it cannot run apps built using GCCE, ARM9E, ARMV6.
What is CodeWarrior?
It's the former, expensive IDE for Symbian. Now replaced by Carbide.c++ which is free.
What is GCCE?
From Forum Nokia Wiki
GCCE (GNU Compiler Collection for Embedded) is an ARM-based compiler used in Symbian OS 9. Before Symbian OS 9, GCC is used to compile for the target. It is intended for building third party applications. It cannot be used to compile the full operating system.
What is RVCT-ARMV6?
It's the proprietary compiler from ARM. It is needed to compile Qt (for now), and for debugging Symbian apps using Qt Creator.
RVCT vs GCCE: http://discussion.forum.nokia.com/forum/showthread.php?t=109299
To run using Emulator:
1. Shutdown the Emulator first (make sure it's not running)
2. Then run app

Error during installation of Qt_Mobility_tech_preview.sis to Emulator:
Certificate error. Contact the application supplier.

Error during Emulator (but ignorable):
C:\Qt\4.6.1-symbian\examples\animation\animatedtiles>make run
call /S60/devices/S60_3rd_FP2_SDK_v1.1/epoc32/release/winscw/udeb/animatedtiles.
exe
Terminate batch job (Y/N)? n

Unhandled exception filter called from program C:\S60\devices\S60_3rd_FP2_SDK_v1
.1\epoc32\tools\make.exe
ExceptionCode = c0000005
ExceptionFlags = 0
ExceptionAddress = 416569
Access violation: write operation at address 428
Solution --> Set Emulator compatibility to Windows XP SP3

Error during make run:
C:\Qt\4.6.1-symbian\examples\animation\animatedtiles>make run
call /S60/devices/S60_3rd_FP2_SDK_v1.1/epoc32/release/winscw/udeb/animatedtiles.exe
C:\S60\devices\S60_3rd_FP2_SDK_v1.1\epoc32\tools\make.exe: [run] Error -1073741819 (ignored)

I got this error during Clean:
make[2]: \S60\devices\S60_3rd_FP2_SDK_v1.1\EPOC32\BUILD\Users\ceefour\Documents\qtcontest\message-merge\MESSAGE-MERGE_0XE6F7F146\WINSCW\MESSAGE-MERGE_0XE6F7F146.WINSCW: No such file or directory
make[2]: *** No rule to make target `\S60\devices\S60_3rd_FP2_SDK_v1.1\EPOC32\BUILD\Users\ceefour\Documents\qtcontest\message-merge\MESSAGE-MERGE_0XE6F7F146\WINSCW\MESSAGE-MERGE_0XE6F7F146.WINSCW'. Stop.
make[1]: *** [CLEANMESSAGE-MERGE_0XE6F7F146] Error 2

I got this error during Build (Symbian Debug):
mwldsym2.exe: Invalid object 'main.o': unknown machine (0x457f)
make[1]: Leaving directory `C:/Users/ceefour/Documents/qtcontest/message-merge'
make -r -f "\S60\devices\S60_3rd_FP2_SDK_v1.1\EPOC32\BUILD\Users\ceefour\Documents\qtcontest\message-merge\WINSCW.make" FINAL CFG=UDEB VERBOSE=-s
Errors caused tool to abort.
make[2]: *** [\S60\devices\S60_3rd_FP2_SDK_v1.1\epoc32\release\WINSCW\udeb\message_merge.exe] Error 1
make[1]: *** [TARGETMESSAGE-MERGE_0XE6F7F146] Error 2
Solution --> http://discussion.forum.nokia.com/forum/showthread.php?t=105186
1) delete all *.o files manually (for some reason "clean project" is not enough)
2) rebuild.
In my case it helped. Problem arose because I created hole project on Linux ("normal" qt) and then copied files (including *.o) to windows machine to play with Carbide.

I got this error during Run:
Starting C:\S60\devices\S60_3rd_FP2_SDK_v1.1\epoc32\release\winscw\udeb\message-merge.exe...
The process could not be started!
--> It means the file does not exist (the Build process fails)

Building Symbian Release + GCCE gives .. last words:
make -r -f "\S60\devices\S60_3rd_FP2_SDK_v1.1\EPOC32\BUILD\Users\ceefour\Documents\qtcontest\message-merge\GCCE.make" TARGET CFG=UREL VERBOSE=-s
make[1]: Entering directory `C:/Users/ceefour/Documents/qtcontest/message-merge'
make -s -C \Users\ceefour\Documents\qtcontest\message-merge -f "MAKEFILE_0XE6F7F146.MK" TO_ROOT=..\..\..\..\.. EPOCBLD=..\..\..\..\..\S60\devices\S60_3rd_FP2_SDK_v1.1\EPOC32\BUILD\Users\ceefour\Documents\qtcontest\message-merge\MAKEFILE_0XE6F7F146\GCCE TO_BLDINF=..\..\..\..\..\Users\ceefour\Documents\qtcontest\message-merge PLATFORM=GCCE CFG=UREL BLD
make -s -r -f "\S60\devices\S60_3rd_FP2_SDK_v1.1\EPOC32\BUILD\Users\ceefour\Documents\qtcontest\message-merge\MESSAGE-MERGE_0XE6F7F146\GCCE\MESSAGE-MERGE_0XE6F7F146.GCCE" UREL
main.cpp
templatesdialog.cpp
templateeditdialog.cpp
mainwizard.cpp
messagemerger.cpp
moc_templatesdialog.cpp
moc_templateeditdialog.cpp
moc_mainwizard.cpp
make[1]: Leaving directory `C:/Users/ceefour/Documents/qtcontest/message-merge'
make -r -f "\S60\devices\S60_3rd_FP2_SDK_v1.1\EPOC32\BUILD\Users\ceefour\Documents\qtcontest\message-merge\GCCE.make" FINAL CFG=UREL VERBOSE=-s
make[1]: Entering directory `C:/Users/ceefour/Documents/qtcontest/message-merge'
make -s -C \Users\ceefour\Documents\qtcontest\message-merge -f "MAKEFILE_0XE6F7F146.MK" TO_ROOT=..\..\..\..\.. EPOCBLD=..\..\..\..\..\S60\devices\S60_3rd_FP2_SDK_v1.1\EPOC32\BUILD\Users\ceefour\Documents\qtcontest\message-merge\MAKEFILE_0XE6F7F146\GCCE TO_BLDINF=..\..\..\..\..\Users\ceefour\Documents\qtcontest\message-merge PLATFORM=GCCE CFG=UREL FINAL
make[1]: Leaving directory `C:/Users/ceefour/Documents/qtcontest/message-merge'
C:\S60\devices\S60_3rd_FP2_SDK_v1.1\epoc32\tools\make.exe: Leaving directory `C:/Users/ceefour/Documents/qtcontest/message-merge'
Exited with code 0.


Prepare the Emulator with Qt :
File -> Open. Install qt_demos.sis
Error: Request application access not granted.

Qt looks awful in E71
Solution --> I was using Dark Personal, switching to Grey Steel works fine.

Build successful (Debug WINSCW), but Error during Run
Starting C:\S60\devices\S60_3rd_FP2_SDK_v1.1\epoc32\release\winscw\udeb\message-merge.exe...
The process could not be started!
Cause: Project name contains '-'. Output filename is message_merge.exe, but tried to run message-merge.exe. Seems like Symbian does not support dash in app names.
Solution: Either
Rename project using underscore "_" instead of dash "-", or
Run message_merge.exe manually

Trouble: App crashes when accessing Qt Mobility / Symbian features
Cause: SYMBIAN.CAPABILITY is not properly specified in the .pro file
See: http://discussion.forum.nokia.com/forum/showthread.php?t=158729
http://discussion.forum.nokia.com/forum/showthread.php?t=90428
After doing this, during installation, it shows dialog for ReadUserData and WriteUserData. So the capability is requested well.
But --> Problem persists! :-(

Trouble: Required application access not granted.
When installing samplephonebook.sis, E71 says "Required application access not granted."
See: http://mobile.antonypranata.com/2006/06/16/interpreting-signing-error-messages-in-s60-3rd-edition/
Hint: Check that your certificate can be used to sign all capabilities needed by your application. For example, if you use self-signed certificate, you can only sign basic set capabilities, i.e. NetworkServices, ReadUserData, WriteUserData, LocalServices and UserEnvironment. If your application requires one of the extended capabilities, for example SwEvent, you cannot sign it with self-signed certificate. In this case, apply for developer certificates from Symbian Signed.

Is Carbide.c++ needed?
If Qt Creator comes with the Nokia C/C++ compiler (WINSCW) then yes, you can ignore Carbide.c++ completely. Of if you don't plan to do any emulator builds ...

Compilation Error release-gcce
Doing make release-gcce on writemessage QtMobility example throws this error:

make -r -f "\S60\devices\S60_3rd_FP2_SDK_v1.1\EPOC32\BUILD\QtMobility\examples\writemessage\GCCE.make" FINAL CFG=UREL VERBOSE=-s

make[2]: *** No rule to make target `\S60\devices\S60_3rd_FP2_SDK_v1.1\epoc32\release\ARMV5\LIB\QtMessaging_tp.dso', needed by `\S60\devices\S60_3rd_FP2_SDK_v1.1\epoc32\release\GCCE\urel\writemessage.exe'. Stop.

make[1]: *** [TARGETWRITEMESSAGE_0XE6E34AD4] Error 2

make[1]: Entering directory `C:/QtMobility/examples/writemessage'

make -s -C \QtMobility\examples\writemessage -f "MAKEFILE_0XE6E34AD4.MK" TO_ROOT=..\..\.. EPOCBLD=..\..\..\S60\devices\S60_3rd_FP2_SDK_v1.1\EPOC32\BUILD\QtMobility\examples\writemessage\MAKEFILE_0XE6E34AD4\GCCE TO_BLDINF=..\..\..\QtMobility\examples\writemessage PLATFORM=GCCE CFG=UREL FINAL

make[1]: Leaving directory `C:/QtMobility/examples/writemessage'

C:\S60\devices\S60_3rd_FP2_SDK_v1.1\epoc32\tools\make.exe: Leaving directory `C:/QtMobility/examples/writemessage'

Exited with code 0.



Running "make sis" also errors, which means the above build was unsuccessful, even though "exit code 0" :

C:\QtMobility\examples\writemessage>make sis
make -s -f Makefile ok_sis
Processing writemessage_release-gcce.pkg...
 Error : Cannot find file : /S60/devices/S60_3rd_FP2_SDK_v1.1/epoc32/release/gcce/urel/writemessage.exe

writemessage_release-gcce.pkg(28) : error: file I/O fault.
file I/O fault, cannot open writemessage_release-gcce_unsigned.sis.

SIS creation failed!
Solution --> Unpack the QtMobility for Symbian SDK binaries.

WINSCW Debug, Build Success, Error during Run:
Starting C:\S60\devices\S60_3rd_FP2_SDK_v1.1\epoc32\release\winscw\udeb\contactsgo.exe...
C:\S60\devices\S60_3rd_FP2_SDK_v1.1\epoc32\release\winscw\udeb\contactsgo.exe exited with code -1073741819
Solution --> Close already running Emulator.

Qt Mobility Contacts when accessing a QContact object crashes on E71, but runs well on emulator
Seems like something to do with "weird" contacts. On my E71, the first two contacts (Groups) are just fine.
I think my Contact LocalId 1460 is somewhat corrupted or has data that Qt Mobility Contacts Symbian cannot cope with. :-(

WINSCW Debug, Build Success, Error During Run:
Starting C:\S60\devices\S60_3rd_FP2_SDK_v1.1\epoc32\release\winscw\udeb\contactsgo.exe...
C:\S60\devices\S60_3rd_FP2_SDK_v1.1\epoc32\release\winscw\udeb\contactsgo.exe exited with code 100
Solution --> Connect to a network, at least loopback. Or just try again.

How to know if WINSCW Debug Qt Mobility Contacts app is good:
Starting C:\S60\devices\S60_3rd_FP2_SDK_v1.1\epoc32\release\winscw\udeb\contactsgo.exe...
Plugin paths: ("C:/Private/e6fe6e03", "C:/resource/qt/plugins", "C:/Private/e6fe6e03")
Looking for plugins in "C:/resource/qt/plugins/contacts" ("mobapicontactspluginsymbian.qtplugin")
Dynamic: found an engine plugin 0x3d9e3828 with name "symbian"
Found engines: ("symbian[]")
Found actions: ()
C:\S60\devices\S60_3rd_FP2_SDK_v1.1\epoc32\release\winscw\udeb\contactsgo.exe exited with code 0

Qt Mobility Contact doesn't run at all on E71, but runs well on emulator
This runs:
    QList<QContactLocalId> contactIds = cm.contacts();
This doesn't:
    QContactFilter filter;
    QList<QContactLocalId> contactIds = cm.contacts(filter);

Can't build Qt Contacts app WINSCW Debug:
make[2]: *** No rule to make target `\S60\devices\S60_3rd_FP2_SDK_v1.1\epoc32\release\WINSCW\udeb\QtContacts.lib', needed by `\S60\devices\S60_3rd_FP2_SDK_v1.1\epoc32\release\WINSCW\udeb\messagemerge.exe'. Stop.
make[1]: *** [TARGETMESSAGE-MERGE_0XEA138C70] Error 2
But --> QtContacts_tp.lib exists !!!
Cause --> Mismatch between Qt Mobility binaries on S60 SDK and the Qt Mobility header files.
Solution -->  Make sure use the exact same Qt Mobility version installed in the S60 SDK and the header files used for development.

mingw-compiled Qt app on Windows: Entry Point Not Found?

I am trying to deploy a release version of my Qt app on Windows, with Qt as shared library.

I have put the following Qt-related shared library DLL files in my application directory:
  • QtCore4.dll
  • QtGui4.dll
  • mingwm10.dll
  • libgcc_s_dw2-1.dll
  • QtContacts_tp.dll (Qt Mobility Contacts DLL)
But I still get this error:


Entry Point Not Found: The procedure entry point _Z15qAddPostRoutinePFvvE could not be located in the dynamic link library QtCore4.dll.

Why is this happening? :-(

Update: Thanks to this QtForum.org thread, it happened because I used the QtCore4.dll and QtGui4.dll from C:\Qt\2010.01\bin. After I used the DLLs from C:\Qt\2010.01\qt\bin, my application works fine! :-)

Related articles:

Sunday, January 24, 2010

Installing Qt 4.6.2 for Symbian SDK on Windows

In this blog post, I will show you how to setup the complete Qt for Symbian S60 development environment properly.

Symbian S60 Development Environment

First we need to setup a Symbian S60 Development Environment. No Qt-related stuff here yet.
  1. Install ActiveState Perl v5.6.1.638 (use ONLY version 5.6.1.638, other versions are not compatible).




    Windows Vista / Windows 7: make sure to run the installer as administrator.
    If not, ActiveState Perl Setup cannot modify the PATH. The workaround is to manually add C:\Perl\bin to the system environment variable PATH.

  2. Install Carbide.c++ IDE (at least version 2.3.0) or Symbian Application Developer Toolkit (ADT) (at least version 1.4, includes Carbide.c++ IDE 2.3.0.)
    I'm curious if Carbide.c++ is still needed when we use Qt Creator as the IDE.
  3. Click Start Menu -> Carbide.c++ -> Configure environment for WINSCW command line.


  4. Install Symbian S60 Platform SDK appropriate for your target device (includes GCCE compiler).
    Since we'll be using Qt for Symbian, it doesn't really matter which S60 Platform SDK you're using, any version above 3rd Edition FP1 (3.1) is good. 5th Edition seems to be a good choice though.




    When asked for Eclipse installation, just skip it.



    During install, if it complains about Java Runtime Environment, simply ignore if because you won't be using it anyway.
    When prompted for installation of CSL ARM Q1C Toolchain, click Yes to install.
For Windows Vista and Windows 7:
  • There are a few compatibility issues
  • You will be prompted by the SDK installer to apply the GCCE patch for MS Vista from <SDK>\plugins\vistapatch\ (<SDK> is C:\S60\devices\S60_5th_Edition_SDK_v1.0 by default). There are instructions in the help.txt file in that directory.
  • The SDK will normally register itself in the file: C:\Program Files\Common Files\Symbian\devices.xml, however on Vista it is forced to create the file in %USERPROFILE%\AppData\Local\VirtualStore\Program Files\Common Files\Symbian\devices.xml. Copy the file manually into the correct location.


  1. Install the Open C/C++ Plug-in for each Symbian Platform SDK you have (though with Qt for Symbian, you just need to have one Symbian SDK).
If you're working on a S60 3rd Edition, FP1 SDK (the earliest version on which Qt will run) you will also need to reinstall the RPipe library. This was installed by the OpenC plugin SDK to the S60_3rd_FP1_3 SDK root directory: \Symbian\9.2\S60_3rd_FP1_3\RPipe_3.1.zip:
  1. Uncompress RPipe_3.1.zip over the SDK root \Epoc32\ tree (e.g. \Symbian\9.2\S60_3rd_FP1_3\Epoc32\).
  2. Download and replace the file <SDK>\epoc32\tools\getexports.exe with getexports.exe
If you want to debug your app on your phone, download AppTRK for your phone and install it. e.g. for Nokia 5800 xpressMusic which runs Symbian S60 5th Edition, you download  s60_5_0_app_trk_3_1_2.sisx.

Qt for Symbian Development Environment

You can then setup Qt for Symbian development environment:
  1. Install Qt for Symbian SDK.
    Make sure to change the Qt folder to C:\Qt\4.6.2-symbian because C:\Qt\4.6.2 will be used for Qt for Windows. Each Qt SDK (e.g. for Windows and for Symbian) will have its own folder. Though you don't have to install Qt SDK for Windows if you only develop for Symbian, it doesn't hurt to name your Qt installation folder clearly.
Install Qt for Symbian on the phone / emulator:
  • Remove previous Qt versions from phone
  • Install either qt_installer.sis (Qt full package) or qtdemos.sis (Qt package + demos) to your phone or emulator.

Setup Qt Creator with Qt for Symbian

  1. Install Qt SDK
  2. Tools -> Options.
  3. Qt4 -> Qt Versions. S60's Qt must be detected from Qt for Symbian SDK.
  4. Qt4 -> S60 SDKs: ?
To get started with Qt Mobility, click here for Qt Mobility SDK Installation for Symbian on Windows tutorial.

For more information about Qt C++ development, check out C++ GUI Programming with Qt 4 (2nd Edition).

To learn Symbian C++ development, I recommend Porting to the Symbian Platform: Open Mobile Development in C/C++ (Symbian Press).

References:
Updates: Updated for Qt 4.6.2.

"QMetaObject::connectSlotsByName: No matching signal for ..." Qt GUI Warning Message

If you get an error message (warning actually) like this:
QMetaObject::connectSlotsByName: No matching signal for on_MainWindow_destroyed()

It means you have an automatically named slot method in the main window or top-level widget.

Qt will automatically connect slots for child widgets, but not the top-level widget.

To solve this problem, you need to:
  1. Rename the slot so it doesn't start with "on_"
  2. Manually connect the slot.
connect(this, SIGNAL(destroyed()), this, SLOT(handle_MainWindow_destroyed()));

I've reported this as Qt Designer bug QT-7582.

References:

Qt Mobility Messaging API on Windows

Qt Mobility Messaging API on Windows supports the MAPI messaging standard. However, this isn't straightforward to set up, as the Qt Mobility documentation states:
On Microsoft Windows, MAPI header files are required to be installed, we recommend installing Visual Studio Express for this purpose.

So what should we do?

I've posted a question on Forum Nokia here.

Qt Mobility Messaging API on Linux

Getting Qt Mobility Messaging API to work on Linux (my Ubuntu Karmic Koala 9.10 system) needs some tricks.

The easiest way of test your setup is by compiling the Qt Mobility example writemessage.

Using my initial installation of Qt Mobility I got this error:
Starting: /usr/bin/make -w
.......
/usr/bin/ld: cannot find -lQtMessaging_tp
collect2: ld returned 1 exit status
make: *** [message-merge] Error 1
Exited with code 2.
Error while building project message-merge
When executing build step 'Make'

The most important error message is "cannot find -lQtMessaging_tp" which means that Qt Mobility Messaging library has not been properly built.



















Qt Mobility on Linux requires QMF.


The Qt Mobility Messaging API documentation points this out:


On Linux QMF is required to be installed and the QMF_INCLUDEDIR and QMF_LIBDIR environment variables set to the messagingframework/src/libraries/qtopiamail and build/messagingframework/image/lib directories respectively.

To install QMF, checkout the latest QMF from Gitorious:
git clone git://gitorious.org/qt-labs/messagingframework.git qt-messagingframework
If you don't have git or don't want to use it, you can also download QMF as tarball archive.
Then build it:
export PATH=/opt/qtsdk-2010.01/qt/bin:$PATH
qmake "QMF_INSTALL_ROOT=$PWD/image" qmf.pro
make
make install
Now you need to rebuild Qt Mobility with Messaging (QMF) support (change paths as necessary):

export PATH=/opt/qtsdk-2010.01/qt/bin:$PATH
export QMF_INCLUDEDIR=/opt/qt-messagingframework/src/libraries/qtopiamail
export QMF_LIBDIR=/opt/qt-messagingframework/image/lib
./configure
make
make install
Make sure it says "Checking QMF ... OK" during configure.
Add the following to your $HOME/.profile script:
necessary):
# Qt Mobility
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/qt-mobility-src-1.0.0-tp2/install/lib:/opt/qt-messagingframework/image/lib
export QMF_INCLUDEDIR=/opt/qt-messagingframework/src/libraries/qtopiamail
export QMF_LIBDIR=/opt/qt-messagingframework/image/lib
Once Qt Mobility Messaging + QMF is set, to use it add the following to your .pro project file:
CONFIG += mobility
MOBILITY = messaging
The writemessage example additionally uses the following workaround to link QMF library:
symbian|win32 {
} else {
# Temporarily link against local qtopiamail lib (should be part of the platform)
LIBS += -L $$(QMF_LIBDIR) -lqtopiamail
}
Then you should be set.

Troubleshooting

If you get this error while building a Qt Mobility Messaging app:
/usr/bin/ld: warning: libqtopiamail.so.1, needed by /opt/qt-mobility-src-1.0.0-tp2/install/lib/libQtMessaging_tp.so, not found (try using -rpath or -rpath-link)
/opt/qt-mobility-src-1.0.0-tp2/install/lib/libQtMessaging_tp.so: undefined reference to `QMailAccountKey::operator|=(QMailAccountKey const&)'
It means you have built Qt Mobility Messaging module properly, but you haven't specified the library path to QMF. See above workaround to link QMF library.
If you get this error when running a Qt Mobility Messaging app:
error while loading shared libraries: libqtopiamail.so.1: cannot open shared object file: No such file or directory
exited with code 127
It means you haven't set QMF_LIBDIR properly. If you have, you may need to restart your computer.

Saturday, January 23, 2010

Installing Qt SDK 4.6.1 with Qt Creator 1.3.1 on Ubuntu

Now that Qt 4.6.1 SDK and Qt Creator 1.3.1 has been released by Nokia, I need to update my previous tutorial on setting up Qt Mobility development.
  1. Download Qt SDK Development Environment.
  2. Install Qt SDK. Launch Terminal, go to the folder where you downloaded Qt SDK distribution, and run:

    chmod +x qt-sdk-linux-x86-opensource-2010.01.bin
    ./qt-sdk-linux-x86-opensource-2010.01.bin
At the end of installation, you will be presented with this message:
Apart from a C++ compiler, a number of development libraries need to be present to enable Qt Creator to build your Qt applications. On Debian and Ubuntu, use the following command in a terminal to make sure they are installed:
sudo apt-get install libglib2.0-dev libSM-dev libxrender-dev libfontconfig1-dev libxext-dev
If you're using QtOpenGL, you'll also need OpenGL development files. You can use the following command to find out which packages to install:
sudo apt-get install libgl-dev libglu-dev
So just do what it tells you to:
sudo apt-get install libglib2.0-dev libSM-dev libxrender-dev libfontconfig1-dev libxext-dev
sudo apt-get install libgl-dev libglu-dev
Make sure you add Qt bin folder to your PATH environment. Edit $HOME/.profile and add:
export PATH=/opt/qtsdk-2010.01/qt/bin/:$PATH 
Now you can build and run Qt applications.
To build Qt Mobility apps, continue to Installing Qt Mobility libraries.

Friday, January 22, 2010

Qt Creator 1.3.1 and Qt 4.6.1 Released

Straight from Nokia's Press Release:


Oslo, 19 January 2010 – Nokia today released version 4.6.1 of Qt: the cross-platform application and UI framework, and version 1.3.1 of Qt Creator: the cross-platform IDE for Qt development .  Qt 4.6.1 brings improvements to developers targeting Symbian, most notably introducing a binary compatibility guarantee as announced with the Qt 4.6.0 release in December 2009.  Both releases introduce bug fixes and optimizations made since the Qt 4.6.0 and Qt Creator 1.3.0 releases.

Also released today are updates to the Qt Visual Studio Add-in and Qt Eclipse Integration, as well as an updated build of the Qt SDK.  All Qt releases are available for download from http://qt.nokia.com/downloads.

Binary Compatibility Guarantee on Symbian
Qt 4.6.1 brings a binary compatibility guarantee for applications built for the Symbian platform, as announced with the release of Qt 4.6.0.  For more information, visit http://qt.nokia.com/products/platform/symbian.

Qt Beta for Maemo 5 Also Released
A Beta of the Qt port to Maemo 5 is now available for download, testing and feedback.  For more information, visit http://qt.nokia.com/developer/qt-for-maemo-developers.

For a detailed list of changes introduced with Qt 4.6.1, consult the changes file found in the packages, or browse the information contained in the Qt Developer Zone at: http://qt.nokia.com/developer/changes/changes-4.6.1. A detailed list of changes in Qt Creator 1.3.1 is available at: http://qt.nokia.com/developer/changes/changes-qtcreator-1.3.1.

Qt Creator 1.3 Help/Documentation Not Working?

I installed Qt Creator IDE 1.3 / Qt 4.6 SDK and having a problem that the Qt Creator Help/Documentation is not working / not showing / blank.

I've found the culprit, and the reason is because:
You have used QtCreator with some Qt version before, and now have installed the same Qt version in a different location: There's a bug   that in this case the information where to get the help file is not updated.

The solution is simple:
Please try explicitly removing the entries in Tools -> Options -> Help, and either restart QtCreator, or add the qch-files from your Qt version explicitly.

Doing the above procedure returns my Qt Creator help content properly.

Wednesday, January 6, 2010

Useful Qt Mobility & Symbian S60 Development Links

Moved to Qt Mobility Links & Resources page.

Installing Qt Mobility Libraries on Windows 7

UPDATE: This article is obsolete. Please refer to the latest article, Installing Qt Mobility Final Libraries on Windows 7.

By following this article, you should be ready to develop Qt Mobility applications on Windows.

Note: This is only for Qt for Windows installation. If you want to develop Qt applications for Symbian on Windows, click here.
  1. Install Qt SDK 4.6 + Qt Creator 1.3 for Windows.
  2. Install Strawberry Perl for Windows (~ 32 MB). The reason why Perl is needed is covered in the later in this article.
  3. Download Qt Mobility library sources.
  4. Unpack Qt Mobility source distribution into a folder without spaces, e.g. C:\qtmobility
  5. Apply this patch to config.tests/make/make.pro. You can use patch tool, but you can edit the file manually (view the patch to see changes).
  6. Launch Qt Command Prompt
  7. Set the PATH to Strawberry Perl :



    set PATH=%PATH%;C:\strawberry\perl\bin
    

  8. Go to your Qt Mobility folder and run configure:



    cd \qtmobility
    configure
    
    This will configure Qt Mobility build with default target directory: C:\QtMobility

  9. Build Qt Mobility:



    mingw32-make
    mingw32-make install

  10. Add C:\qtmobility\lib folder to your PATH environment variable (more on this below).
  11. To add Qt Mobility documentation in Qt Creator: Go to Tools -> Options -> Help -> Add. Then browse C:\qtmobility/doc/qch/qtmobility.qch
Now you're ready to develop with Qt Mobility on Windows. Check out Qt Mobility Quickstart App for an example.



Setting Environment Variables

In order to use Qt Mobility some environment variables need to be extended to locate the libraries, which are placed in the lib directory of the install path.

On Windows: PATH should be extended to include: C:\%TARGET_DIR%\lib

On my setup this folder is: C:\qt-mobility-src-1.0.0-tp2\lib



PATH can be extended through Start -> Settings -> Control Panel -> System -> Advanced -> Environment variables. Under System variables, select "PATH", click "Edit..." and append your Qt Mobility lib folder.

Reboot your system to apply your changes to system environment variables.

You're now ready to develop Qt Mobility applications in Windows. :-)

Problems I Encountered... So You Don' Have To


I first tried to unpack Qt Mobility into My Documents, but I can't compile it:
C:\Users\ceefour\Documents\qt-mobility-src-1.0.0-tp2>configure
C:\Users\ceefour\Documents\qt-mobility-src-1.0.0-tp2
Checking available Qt
4.6.0
Checking make
 "Cannot find 'nmake', 'mingw32-make' or 'make' in your PATH"
 "Aborting."
I tried to move it to a top-level folder (C:\qtmobility) but still getting the same error.

After reading Forum Nokia thread: Qt Mobility problem, I tried to reboot my computer, but didn't help. There's also steps to install Qt Mobility for Symbian.

After further investigation leads me that configure determines its expected build system to be symbian-sbsv2 based on running qmake on config.tests\make\make.pro :
C:\qt-mobility-src-1.0.0-tp2>qmake config.tests\make\make.pro
Project MESSAGE: symbian-sbsv2
Project MESSAGE: symbian-sbsv2
Project MESSAGE: symbian-sbsv2

C:\qt-mobility-src-1.0.0-tp2>make
'make' is not recognized as an internal or external command,
operable program or batch file.
So it's looking for make.exe, which doesn't exist on my system.

I harcoded BUILDSYSTEM=win32-mingw by patching configure.bat here:
...
    for /f "tokens=3" %%i in ('%QT_PATH%qmake %SOURCE_PATH%\config.tests\make\make.pro 2^>^&1 1^>NUL') do set BUILDSYSTEM=%%i

    set BUILDSYSTEM=win32-mingw

    if %BUILDSYSTEM% == symbian-abld (
...
Update: Use this patch.

and now configure seem to work...
C:\qt-mobility-src-1.0.0-tp2>configure
C:\qt-mobility-src-1.0.0-tp2
Checking available Qt
4.6.0
Checking make
hello
... mingw32-make found.

Start of compile tests
Checking LBT
'Y_MAKEPROJECT_LOG' is not recognized as an internal or external command,
operable program or batch file.
... Not Found
'compile' is not recognized as an internal or external command,
operable program or batch file.


"Generating Mobility Headers..."
The system cannot find the file specified.
'perl' is not recognized as an internal or external command,
operable program or batch file.
'perl' is not recognized as an internal or external command,
operable program or batch file.
'perl' is not recognized as an internal or external command,
operable program or batch file.
'perl' is not recognized as an internal or external command,
operable program or batch file.
'perl' is not recognized as an internal or external command,
operable program or batch file.
'perl' is not recognized as an internal or external command,
operable program or batch file.
'perl' is not recognized as an internal or external command,
operable program or batch file.
'perl' is not recognized as an internal or external command,
operable program or batch file.
'perl' is not recognized as an internal or external command,
operable program or batch file.

Running qmake...
Reading C:/qt-mobility-src-1.0.0-tp2/src/src.pro
 Reading C:/qt-mobility-src-1.0.0-tp2/src/global/global.pro
 Reading C:/qt-mobility-src-1.0.0-tp2/src/serviceframework/serviceframework.pro
 Reading C:/qt-mobility-src-1.0.0-tp2/src/bearer/bearer.pro
 Reading C:/qt-mobility-src-1.0.0-tp2/src/location/location.pro
 Reading C:/qt-mobility-src-1.0.0-tp2/src/contacts/contacts.pro
 Reading C:/qt-mobility-src-1.0.0-tp2/src/multimedia/multimedia.pro
 Reading C:/qt-mobility-src-1.0.0-tp2/src/publishsubscribe/publishsubscribe.pro
 Reading C:/qt-mobility-src-1.0.0-tp2/src/versit/versit.pro
 Reading C:/qt-mobility-src-1.0.0-tp2/src/systeminfo/systeminfo.pro
Reading C:/qt-mobility-src-1.0.0-tp2/tools/tools.pro
 Reading C:/qt-mobility-src-1.0.0-tp2/tools/servicefw/servicefw.pro
 Reading C:/qt-mobility-src-1.0.0-tp2/tools/servicexmlgen/servicexmlgen.pro
 Reading C:/qt-mobility-src-1.0.0-tp2/tools/vsexplorer/vsexplorer.pro
 Reading C:/qt-mobility-src-1.0.0-tp2/tools/qcrmlgen/qcrmlgen.pro
Reading C:/qt-mobility-src-1.0.0-tp2/plugins/plugins.pro
 Reading C:/qt-mobility-src-1.0.0-tp2/plugins/contacts/contacts.pro
 Reading C:/qt-mobility-src-1.0.0-tp2/plugins/multimedia/multimedia.pro
  Reading C:/qt-mobility-src-1.0.0-tp2/plugins/multimedia/m3u/m3u.pro
  Reading C:/qt-mobility-src-1.0.0-tp2/plugins/multimedia/phonon/phonon.pro
  Reading C:/qt-mobility-src-1.0.0-tp2/plugins/multimedia/audiocapture/audiocapt
ure.pro
Reading C:/qt-mobility-src-1.0.0-tp2/doc/doc.pro
 Reading C:/qt-mobility-src-1.0.0-tp2/doc/src/snippets/snippets.pro
  Reading C:/qt-mobility-src-1.0.0-tp2/doc/src/snippets/qtcontactsdocsample/qtco
ntactsdocsample.pro

configure has finished. You may run mingw32-make to build the project now.
Time to run mingw32-make and pray:
...
g++ -c -O2 -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT
-DQT_DLL -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS
_QMAIN -I"c:\Qt\2009.05\qt\include\QtCore" -I"c:\Qt\2009.05\qt\include\QtGui" -I
"c:\Qt\2009.05\qt\include" -I"c:\Qt\2009.05\qt\include\QtContacts_tp" -I"..\..\.
.\..\src\global" -I"..\..\..\..\src\contacts" -I"..\..\..\..\src\contacts\reques
ts" -I"..\..\..\..\src\contacts\filters" -I"..\..\..\..\src\contacts\details" -I
"c:\QtMobility\include" -I"c:\Qt\2009.05\qt\include\ActiveQt" -I"..\..\..\..\bui
ld\Release\qtcontactsdocsample\moc" -I"c:\Qt\2009.05\qt\mkspecs\win32-g++" -o ..
\..\..\..\build\Release\qtcontactsdocsample\moc_requestexample.o ..\..\..\..\bui
ld\Release\qtcontactsdocsample\moc\moc_requestexample.cpp
g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-rel
oc -Wl,-s -mthreads -Wl -Wl,-subsystem,windows -o ..\..\..\..\bin\examples\qtcon
tactsdocsample.exe ../../../../build/Release/qtcontactsdocsample/qtcontactsdocsa
mple.o ../../../../build/Release/qtcontactsdocsample/moc_requestexample.o  -L"c:
\Qt\2009.05\qt\lib" -lmingw32 -lqtmain -LC:\qt-mobility-src-1.0.0-tp2/lib -LC:\Q
tMobility/lib -lQtContacts_tp -lQtGui4 -lQtCore4
mingw32-make[4]: Leaving directory `C:/qt-mobility-src-1.0.0-tp2/doc/src/snippet
s/qtcontactsdocsample'
mingw32-make[3]: Leaving directory `C:/qt-mobility-src-1.0.0-tp2/doc/src/snippet
s/qtcontactsdocsample'
mingw32-make[2]: Leaving directory `C:/qt-mobility-src-1.0.0-tp2/doc/src/snippet
s'
mingw32-make[1]: Leaving directory `C:/qt-mobility-src-1.0.0-tp2/doc'

C:\qt-mobility-src-1.0.0-tp2>_
The build took a few minutes and it seems everything's fine.

P.S.: I could have just "given up" and install Symbian S60 SDK first. :-)

Compiling Qt Mobility with Debug enabled

If you try to develop a Qt Mobility app and using the Debug configuration (which is default), you'll get errors similar to these:

Running build steps for project locale-qt...
Starting: c:/qt/2009.05/qt/bin/qmake.exe C:/Users/ceefour/Documents/locale-qt/locale-qt.pro -spec win32-g++ -r
Exited with code 0.
Starting: C:/Qt/2009.05/mingw/bin/mingw32-make.exe -w
mingw32-make: Entering directory `C:/Users/ceefour/Documents/locale-qt'
C:/Qt/2009.05/mingw/bin/mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory `C:/Users/ceefour/Documents/locale-qt'
g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -mthreads -Wl -Wl,-subsystem,windows -o debug\locale-qt.exe debug/main.o debug/mainwindow.o debug/moc_mainwindow.o -L"c:\Qt\2009.05\qt\lib" -lmingw32 -lqtmaind -LC:\qtmobility/lib -lQtSystemInfo_tpd -lQtGuid4 -lQtNetworkd4 -lQtCored4
mingw32-make[1]: Leaving directory `C:/Users/ceefour/Documents/locale-qt'
mingw32-make: Leaving directory `C:/Users/ceefour/Documents/locale-qt'
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
mingw32-make[1]: *** [debug\locale-qt.exe] Error 1
mingw32-make: *** [debug] Error 2
Exited with code 2.
Error while building project locale-qt
When executing build step 'Make'

You have two choices:
  1. Build your project using Release configuration.
  2. Build Qt Mobility with Debug enabled as well.
To build Qt Mobility with Debug enabled, simply add the argument -debug to configure in the steps above:

configure -debug

Then repeat the build process as usual.

Installing Perl


I noticed some errors early in the "configure" process:
"Generating Mobility Headers..."
Access is denied.
'perl' is not recognized as an internal or external command,
operable program or batch file.
...
This is one reason why I hate hesitate to use Windows. Qt Mobility's include folder, which should contain the header files, is still empty. Time to install a Perl interpreter.

Get Strawberry Perl for Windows (~ 32 MB).

Strawberry Perl automatically adds itself to your PATH system variable, you can check this by running perl -v :
C:\strawberry>perl -v

This is perl, v5.10.1 (*) built for MSWin32-x86-multi-thread

Copyright 1987-2009, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.
Unfortunately, Qt Command Prompt sets its own PATH environment variable, overriding. Before running configure, do:
set PATH=%PATH%;C:\strawberry\perl\bin
Now you can configure and build Qt Mobility on Windows properly.

See also: