Thursday, January 28, 2010

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.