Tag Archives: qtcreator

Using Libraries On Symbian And Windows

I’ve had a few people recently contacting me and asking me how i managed to get twitter authentication working in SymPaper, im not going to go specifically into how i got oauth working but this post will be about how i got third party libraries in working my Qt Symbian apps using the fantastic KQOauth library as an example.

But first the reason for needing a library, Oauth 1.0 is a nightmare to work with, i understand why its in theory good but i hate how its implemented. I often get requests to make apps for a number of different web services and will always pursue each one until the point that i see Oauth 1.0! However for SymPaper sharing articles via twitter was pretty essential so i looked at writing my own implementation of Oauth in Qt which got about half way before i gave up! A quick google brings up a number of examples of how to implement OAuth in Qt and QML like this one that just didn’t work at all. After a while of trying code like that out i came across KQOauth a library written in Qt which claimed to work for Symbian! I quickly downloaded and compiled the source code and had it working for my Desktop and Qt Simulator targets however when trying to deploy to my phone i had to install another sis file with the library on. Not such a problem if you’re making apps just for yourself and a couple others to use but a big problem if you’re trying to distribute those apps to as many people as possible! I then ran into another stumbling block! The remote compiler for QtCreator didn’t work with statically linked libraries, i found a bug report and commented on it but had no reply.
So I had to think of a new way of getting around the issue and here is what i did:

  • Take the KQOAuth source code and include it all in my project!

That’s it! quick and dirty but it works, well not quite! I found that whilst including the library’s source code in my project meant it worked on my device, it also stopped my Desktop and Qt Simulator instances compiling for the project, not so good since deploying to a Symbian phone actually takes (in my opinion) ages! Especially since i like to build my apps on the desktop up until i have to add mobile specific functionality (Actually all my apps run properly on my desktop, SymPaper just can’t send SMS!). So i had to use some conditional coding in my project file to only use the included library files when on the Symbian device and to use the System libraries when on the windows target (which also include the Qt Simulator!).

Here’s a screenshot of what my final project file looked like for SymPaper:

SymPaper Project File

SymPaper Project File


And to make things even easier here a dump the relevant bits of that code for you to copy and paste into your own project files:

windows:{
    INCLUDEPATH += c:/Users/Talv/Documents/Qt/kqoauth/include
    INCLUDEPATH += c:/Users/Talv/Documents/Qt/kqoauth/src
    LIBS += -Lc:/Users/Talv/Documents/Qt/kqoauth/lib -lkqoauthd0
}

symbian:{
    SOURCES += \
        koauth/kqoauthutils.cpp \
        koauth/kqoauthrequest.cpp \
        koauth/kqoauthmanager.cpp \
        koauth/kqoauthauthreplyserver.cpp
    HEADERS += \
        koauth/kqoauthutils.h \
        koauth/kqoauthrequest_p.h \
        koauth/kqoauthrequest.h \
        koauth/kqoauthmanager_p.h \
        koauth/kqoauthmanager.h \
        koauth/kqoauthglobals.h \
        koauth/kqoauthauthreplyserver_p.h \
        koauth/kqoauthauthreplyserver.h
}

Once that has been done there’s just one more thing left to do to get your library working in your app properly, in the Class or Header files where you want to use the library just remember to reference the correct instance of the library. So for Symbian devices you want to use the included files, and for other targets use the system library:

#ifdef Q_OS_SYMBIAN
    #include "koauth/kqoauthrequest.h"
    #include "koauth/kqoauthmanager.h"
#else
    #include <QtKOAuth>
#endif

And you’re done! Code away as usual!

You now have a third party library working on your symbian devices that works with the remote compiler and doesn’t stop your other targets working! Let me know if this has been useful and how you get on!

S60v5 Apps Failing OVI Store QA

Since the Nokia started letting QML apps into the Ovi store i’ve been trying to use it in my user interfaces as much as possible, this means compiling against the newest supported version of Qt, which is 4.7.3. I use the remote compiler in the QtCreator IDE to produce the *.sis files that are distributed in the ovi store however since moving to Qt4.7.3 all of my apps have been failing QA for publishing to the older Symbian^1 / S60v5 platform.

I couldn’t find any apparent reason so i emailed the Ovi publish team to find out what was going on this was the response i got:

Hi Talv,

Thank you for your interest in publishing your Qt app with Ovi Store. Sorry for
the delay, it took me a while to get Qt SDK’s Remote Compiler to work because
of corporate networking settings.

Qt 4.7.3 is indeed supported for Symbian^1 (S60 5th Ed.) devices. Unfortunately
Qt SDK 1.1 contains a bug that leaves the S60 5th Ed. platform ID out of the
generated SIS files. The missing platform ID causes the “Application not
compatible with phone” message to appear.

You may refer to this bug report for further information and a workaround for
local build environments.

http://bugreports.qt.nokia.com/browse/QTSDK-702

You can specify the compatible platforms in your Qt project file instead of
using the SDK defaults. This method works with both local build environments
and Remote Compiler. An example for an app that is compatible with Symbian^1
devices is below.


symbian {
# Remove all the existing platform dependencies
default_deployment.pkg_prerules -= pkg_platform_dependencies

# Add a dependency for just Symbian^1 and later devices
supported_platforms = \
"; Application supports Symbian^1" \
"[0x1028315F], 0, 0, 0, {\"Symbian^1\"}"

my_deployment.pkg_prerules += supported_platforms

DEPLOYMENT += my_deployment
}

Please let me know if you have any other questions about this issue.

Kind Regards,

Bron
Ovi Store Developer Support

To summarise:

  • There’s nothing wrong with your apps its a bug in the current Qt SDK
  • Add the code fragment above to your project file to solve the issue

Builds of SymFTP and SymMeme QML with these changes have already been sent to the Ovi store for QA, so Symbian^1 users can get hold of my apps asap!