I have cross-compiled executable file from QT 4.8.7. I am running it on a Raspberry PI (Ubuntu), with QT 4.8.7 and QT declarative module installed. When i run the executable file on my raspberry pi, i got the error message : undefined symbol: _ZN7QWidget8qwsEventEP8QWSEvent. I don't know why I am getting this error as both installed QT versions are the same and arm-linux-gcc toolchain is same. Note : I am using Raspberry pi 2 Model B ver 1.1 and Ubuntu Mate Os.

  • The desktop Ubuntu which I am cross-compiling from as shown via lsb_release:
$ lsb_release -id
  • The exact version of Ubuntu MATE 16.04 installed on the Raspberry Pi 2B v1.1:
$ lsb_release -id
  • The exact cross-compiler version on my build-system:
$ arm-linux-gnueabihf-g++ --version
  • On the Pi my Qt 4 package version is as follows:
$ apt-cache policy libqt4-declarative
  Installed: 4:4.8.7-dfsg-5ubuntu2
  Candidate: 4:4.8.7-dfsg-5ubuntu2
  • On the Ubuntu 16.04 desktop build environment the package version is:
$ apt-cache policy libqt4-declarative:armhf
  • On the Pi, checking the Qt library binary shows it using X11, not QWS:
$ strings /usr/lib/arm-linux-gnueabihf/libQtDeclarative.so.4 | egrep 'qwsEvent|x11Event'
  • On the desktop build environment:
$ strings /usr/lib/arm-linux-gnueabihf/libQtDeclarative.so.4 | egrep 'qwsEvent|x11Event'
  • To install the Qt library in my cross-compiling build environment I did (???select the correct one and remove the other two):

    • Configured and cross-compiled the Qt libraries from source (bad, and almost guaranteed to cause the windowing mismatch problem @jdonald linked)
    • Ran sudo dpkg --add-architecture armhf, ensured my /etc/apt/sources.list had the correct Xenial armhf ports sources, and ran sudo apt-get update; sudo apt-get install libqt4-dev:armhf (good)
    • Installed from a different source (???)
  • Searching for references to different windowing systems in my build directory turns up the following:

$ egrep -r qwsEvent my_build_dir/*
$ egrep -r x11Event my_build_dir/*
  • You should post more info like the model of pi, Ubuntu version and the architecture you compiled the executable on. – The Coding Clan Aug 17 '19 at 8:01
$ c++filt _ZN7QWidget8qwsEventEP8QWSEvent

If you look at the documentation, this method is only available if Qt is built under the windowing configuration of Qt for Embedded Linux (Q_WS_QWS), a legacy system that was removed in Qt 5. If Ubuntu is anything like Raspbian, Qt is built for X11 instead and you only have QWidget::x11Event(_XEvent*) available.

Possibly the reason you're even able to hit this problem may be due to cross-compiling Qt yourself, which allows you to set a different configuration from the target platform. If you use the standard Ubuntu armhf packages on your build machine then this would avoid a mismatch and show linker errors at build time rather than postponing until load time. If you've done the required dpkg --add-architecture and installed the appropriate APT sources, the installation command on the host PC would be:

sudo apt install libqt4-declarative:armhf

[1] http://m-embedded.blogspot.com/2015/07/build-qt4-embedded-on-host-pc.html shows a similar example of a developer who cross-compiled Qt itself for QWS while the installed libraries on a BeagleBone Black are for X11 and thus a mismatch.

  • I have given the command "sudo apt install libqt4-declarative:armhf" but it is showing like "libqt4-declarative is already the newest version (4:4.8.7+dfsg-5ubuntu2)". so i have already have the new version. Actually I have cross compiled QT on another ubuntu pc which have QT 4.8.7 installed and when I am running this file on Raspberry Pi board which is configured with Ubuntu Mate and QT 4.8.7, I am getting this error "symbol lookup error: undefined symbol: _ZN7QWidget8qwsEventEP8QWSEvent ". @jdonald – Mehta Aug 21 '19 at 5:55
  • I'm afraid your language is unclear (both in your original post and followup comment). Did you cross-compile Qt (the big, gigabytes-full of libraries) on that Ubuntu PC? If so, you should not and should instead install the binary package. Or do you mean you only cross-compiled your smaller program and linked it with the prepackaged libqt4-declarative:armhf binaries? If so that's okay. Either way, as I wrote above you should make sure you avoid any references to QWidget::qwsEvent(QWSEvent*) a.k.a. _ZN7QWidget8qwsEventEP8QWSEvent and replace those with QWidget::x11Event(_XEvent*). – jdonald Aug 21 '19 at 13:53
  • I hv cross compiled 1 small example program in QT like "behavior-example"which is in QT 4.8.7 example folder. I hv already linked it with libqt4-declarative:armhf....but same error i got.... Nd what should i do to replace with Qwidget::x1qEvent(_XEvent*)??? – Mehta Aug 21 '19 at 14:02
  • Got it, no direct references to qwsEvent in your code, but potentially in generated code or the libraries. See this post this blog post for someone with the same unresolved situation (same function different name mangling). Please answer @The Coding Clan by editing your original question to include the Ubuntu versions (16.04 or 18.04?) both for build host and the target, plus exact QtDeclarative package versions (apt-cache info libqt4-declarative:armhf). Also grep for qwsEvent in your binaries+libraries. – jdonald Aug 21 '19 at 14:33
  • How can i find the version of QtDeclarative Module ?? when i enter this command "apt-cache info libqt4-declarative:armhf", it is showing like E: Invalid operation info. – Mehta Aug 24 '19 at 5:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.