Important: Please read the Qt Code of Conduct -

Cross compilation with X11

  • Hi all,

    I want to cross compile Qt source for arm which is running ubuntu 12.10, which is similar that of desktop environment.
    I need Qt application to run on the top of the Gnome.

    How do I cross compile Qt source?

    In found some solutions i.e :
    @./configure -arch arm -xplatform $customMkspecDirName@

    Is that all needed to be given for configuring Qt source or anything along with that?

    Also what changes should be made in qmake.conf file?
    QMAKE_INCDIR_X11 and QMAKE_LIBDIR_X11 what it should contain?

    Please help me to gain knowledge how to run Qt with X11.
    Thank you in advance :)

  • Lifetime Qt Champion


    You need to also provide the cross-compiled X11 libraries for Qt to link to.

    What board are you targeting ?

  • I am targeting a board similar to that of Beagleboard-Xm.

    Cross compiled X11 libraries? How do I do it?

    Can you please suggest me.

  • Lifetime Qt Champion

    The most straightforward way to do that, is to install the corresponding dev packages on your target and use it as sysroot to build Qt

  • Sorry I dint understand. Can elaborate little?

    I tried Cross compiling Qt source with the below configure options:
    @./configure -prefix /usr/local/Qt_4.8.6 -arch arm -platform linux-g++-32 -xplatform linux-arm-linaro-g++ -static -nomake demos -nomake examples -no-openssl -no-sql-sqlite -no-phonon -no-phonon-backend -no-webkit -no-mmx -no-rpath -no-3dnow -no-sse -no-sse2 -no-glib -no-cups -no-largefile -no-accessibility -no-openssl -little-endian -fontconfig -no-sql-mysql -no-sql-odbc -no-sql-psql -nomake docs -nomake translations -qt-freetype -qt-libjpeg -qt-libpng@

    But I got the following error and configuration stopped:
    @Basic XLib functionality test failed!
    You might need to modify the include and library search paths by editing
    QMAKE_INCDIR_X11 and QMAKE_LIBDIR_X11 in /home/chaitra/Desktop/qt-everywhere-opensource-src-4.8.6/mkspecs/linux-arm-linaro-g++.@

    I have installed all the dependies as stated in
    "this": link
    Still the result is same.

    Please suggest me to cross compile the X11 libraries because the above error while configuring is due to same reason.

    Thank you.

  • Lifetime Qt Champion

    What you did is install the dependencies to build Qt for your computer. What you need to do is install them for your target. So the simplest way is to login to your target, install all the needed dependencies.

    The you can e.g. mount your device filesystem in a place on your computer using e.g. sshfs and give the -sysroot parameter to configure pointing to where your mounted the device fs. It should then pick the headers and libraries from there and continue its work

  • Hi,

    I successfully cross compiled Qt source using sysroot.
    Thank you so much.

    I have one more problem.
    I created a sample application and tried to compile it.
    As it was not accessible for the sysroot or something else I was unable to build my QT application in the Qt creator.

    I got the following error:
    @cc1plus: error: /media/SSHFS_X11/cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-linux/install/arm-linux-gnueabihf/libc/include: Permission denied
    cc1plus: error: /media/SSHFS_X11/usr/include/.: Permission denied
    cc1plus: error: /media/SSHFS_X11/usr/include/arm-linux-gnueabihf: Permission denied
    cc1plus: error: /media/SSHFS_X11/usr/include: Permission denied@

    I tried to make changes in Tools->Options->Build and Run->Kits->sysroot I tried to include the mounted file system, but it was blank and nothing I could include it from my mounted file system SSHFS_X11.

    Can I know what I need to do now? Please help me to resolve this issue.

    Thank you.

  • Lifetime Qt Champion

    Did you check that you have read rights on you mounted file system ? Also did you mount it to the same place you used when cross-compiling Qt ?

  • Hi,
    Yes I have mounted on the place as I had while cross compiling.

    I have permission to read/write but as a root. Its as shown below:
    @drwxr-xr-x 2 root root 4096 Jun 11 2013 cdrom
    drwxrwx--- 2 root vboxsf 4096 Jun 12 2013 sf_UbuntuSharedFolder
    drwxr-xr-x 1 root root 4096 Oct 6 11:28 SSHFS_X11@

  • Hi,

    I resolved that issue. The problem was while mounting the file system using ssfhs I had not provided an option i.e allow_other. So it was showing permission denied error
    Thank you.

  • Hi,

    All my problem solved. Now Qt application is running on gnome.
    Thank you so much for the help :) :)

  • Lifetime Qt Champion

    You're welcome !

    Since you have your application working now, please update the thread title prepending [solved] so other forum users may know a solution has been found :)

  • Hi,

    Ya sure I will do it.
    I have one more problem. Keyboard is not working after running the application.
    How can I enable it?

  • Lifetime Qt Champion

    How are you starting your application ? What type of keyboard is it ?

  • I am using USB Keyboard.
    I am starting the application by giving the command in the terminal:

    Keyboard works till application runs after application start running it doesn't work.

  • Lifetime Qt Champion

    Still using X11 ?

  • Yes Qt application running on X11.

  • @SGaist
    Hi, I have followed same steps. It's works.
    Is it possible build without target device ?
    Could you please help me on this. Thanks in advance!

  • Lifetime Qt Champion

    @thanga said in [SOLVED]Qt cross compilation with X11:

    Is it possible build without target device ?

    Can you explain what you mean?
    You can build without target device if you have a sysroot for it.

  • @jsulm

    I have mounted target device on /media/SSHFS_X11/ path on host machine (Ubuntu). While mounted Qt getting build, If I disconnect the target device. I am getting following error:
    Basic XLib functionality test failed!
    You might need to modify the include and library search paths by editing
    QMAKE_INCDIR_X11 and QMAKE_LIBDIR_X11 in /home/lolveley/bin/qt-x11-opensource-src-4.5.1/mkspecs/linux-g++.

    May I know how to build without target device ? And how to configure sysroot on host (Ubuntu) machine ?

    Could you please help me on this...

  • Lifetime Qt Champion

    @thanga Just create a directory and copy the content of your target device to that directory. Then use this directory as your sysroot instead of /media/SSHFS_X11.

  • @jsulm
    I have copied /usr dir files to /media/SSHFS_X11, and tried to build But still and getting following error,
    Basic XLib functionality test failed!
    You might need to modify the include and library search paths by editing
    QMAKE_INCDIR_X11 and QMAKE_LIBDIR_X11 in /home/lolveley/bin/qt-x11-opensource-src-4.5.1/mkspecs/linux-g++.

    Is it required to copy all the contents or /usr dir is fine?

    Target device also Ubuntu OS stand alone device.

  • Lifetime Qt Champion

    @thanga You need to copy everything what is needed. You should copy at least /usr/lib and /usr/include, probably /lib as well.
    It should then look like:


    Call configure with -v parameter to see what exactly is missing if it says "Basic XLib functionality test failed!".

  • Lifetime Qt Champion

    If you don't use the same folder as you did when configuring the first time then you should point configure to the new location. Note that you should do a build from scratch to avoid any leftovers from interfering.

  • @jsulm
    I have copied /usr/lib, /usr/include and /lib files to /media/SSHFS_X11/. I am getting following error now,

    /media/SSHFS_X11/usr/include/./X11/Xlib.h:38:23: fatal error: sys/types.h: No such file or directory
    compilation terminated.
    make: *** [xlib.o] Error 1
    XLib disabled.
    Basic XLib functionality test failed!
    You might need to modify the include and library search paths by editing
    QMAKE_INCDIR_X11 and QMAKE_LIBDIR_X11 in /home/user/qt-everywhere-opensource-src-4.8.6/mkspecs/qws/linux-arm-linaro-g++.

  • Lifetime Qt Champion

    @thanga said in [SOLVED]Qt cross compilation with X11:


    Does this header file exist in /media/SSHFS_X11/usr/include ?

  • @jsulm

    No. sys/types.h file is not available. But following files are present on /media/SSHFS_X11/usr/include.

    aio.h crypt.h FLAC i386-linux-gnu ltdl.h neteconet protocols setjmp.h sudo_plugin.h utmp.h
    aliases.h ctype.h fmtmsg.h iconv.h malloc.h netinet pthread.h sgtty.h syscall.h utmpx.h
    alloca.h dbus-1.0 fnmatch.h ieee754.h math.h netipx pty.h shadow.h sysexits.h values.h
    a.out.h dirent.h fstab.h ifaddrs.h mcheck.h netiucv pwd.h signal.h syslog.h video
    argp.h dlfcn.h fts.h inttypes.h memory.h netpacket python2.7 sndfile.h tar.h vorbis
    argz.h drm ftw.h langinfo.h mm netrom rdma sndfile.hh termio.h wait.h
    ar.h elf.h _G_config.h lastlog.h mntent.h netrose re_comp.h sound termios.h wchar.h
    arpa endian.h gconv.h libdrm monetary.h nfs regex.h spawn.h tgmath.h wctype.h
    asm-generic envz.h getopt.h libgen.h mqueue.h nl_types.h regexp.h stab.h thread_db.h wordexp.h
    assert.h err.h gettext-po.h libintl.h mtd nouveau resolv.h stdint.h time.h X11
    autoopts errno.h GL libio.h nautilus-sendto nss.h rpc stdio_ext.h ttyent.h xcb
    autosprintf.h error.h glob.h libltdl net obstack.h rpcsvc stdio.h ucontext.h xen
    byteswap.h execinfo.h gnu-versions.h limits.h netash ogg sched.h stdlib.h ulimit.h xf86drm.h
    c++ fcntl.h grp.h link.h netatalk paths.h scsi string.h unistd.h xf86drmMode.h
    complex.h features.h gshadow.h linux netax25 poll.h search.h strings.h ustat.h xlocale.h
    cpio.h fenv.h gstreamer-0.10 locale.h netdb.h printf.h semaphore.h stropts.h utime.h xorg

  • Lifetime Qt Champion

    Did you do a full copy of the sysroot over to your desktop ?

    On a side note, unless you're locked to that version, at least use the latest of the Qt 4 series which is 4.8.7. Even better if you migrate to Qr 5.

  • @SGaist

    Yes. I have copied all the files. May I know how to configured sysroot on local desktop ? Could please tell me the steps.

  • Lifetime Qt Champion

    @thanga "Could please tell me the steps" - we already did.
    Does this file exist on your target device?
    Did you copy recursively (I mean: including subdirectories)?

  • @jsulm
    Thanks!! I have copied target device files, I can able to create QT qmake file now.

    I need build application without adding target device on Qt Creator. is it possible to build like this ??

  • Lifetime Qt Champion

    What do you mean by "without adding target device on Qt Creator" ?

  • @SGaist

    We are mounting and adding Beagleboard device (on Qt Creator) for compiling Qt application.

    Add device on Qt Creator:
    Qt Creator -> Tools -> Devices -> Add Device

    Mounting Device (Beagleboard):

    Is it possible to compile Qt application without Beagleboard device ?

  • Lifetime Qt Champion

    If you don't want to mount the device root filesystem while developing then you have to provide a sysroot to work with.

  • @SGaist
    thanks, I got confused on providing "sysroot".
    I am looking for a way to cross compile Qt application for beaglebone without adding and mounting to Host PC either through SCP or as file system. Because to update and rebuild the Qt application each time its leading to mount the device to PC host.
    Is there any other way to do? or it is not possible !!!

  • Lifetime Qt Champion

    If you don't want to mount your device while developing for it then you have to copy its root filesystem on your computer and use that copy as sysroot when cross-compiling Qt. You will also have to keep that copy up to date if you need to add a new dependency for your application.

  • @SGaist
    Thanks! How to compile Qt application without device ?

    We are adding device on Qt Creator, is it possible to compile the application without device ? Please check the below link for your reference.

    Qt Creator link:

  • Lifetime Qt Champion

    I already wrote it several times: if you want to cross-compile without any device connected, then copy the root filesystem of your device on your desktop machine and cross-compile Qt using it.

    One thing to be clear: if you want to run your cross-compiled application, then you need your device accessible to run said application.

    Out of curiosity, why do you want that much to cross-compile an application without any device connected to confirm it runs properly ?

  • @SGaist
    One of our device is not on network and cannot be mounted. We would like to cross compile the code using QTCreator and copy the executable manually on the target using a SD Card. Let us know if this is possible.
    If yes, then what should be the hostname and credentials in QTCreator Add Device screen?

  • Lifetime Qt Champion

    Since your device is out of reach, it doesn't make sense to put anything there. Just don't add any device. Build your executable and then copy it on your SD card.

Log in to reply