AnsweredAssumed Answered

Creating a .desktop for yocto distribution Qt Creator which requires environment variables

Question asked by Ossian Riday on Oct 22, 2014
Latest reply on Oct 23, 2014 by gusarambula

I know some love the command line and are OK with executing a modified version of qtcreator.sh such as described in the following link:

Setup QT Creator with Yocto Build

 

But, I like having a Qt Creator desktop icon/launcher in ubuntu. The following tips will hopefully be helpful to others that would like to do the same.

Recently the master yocto Qt recipe was updated to fix some environment path issue with qmake, as part of this update the setting of some of the Qt environment variables were moved from environment-setup-cortexa9hf-vfp-neon-poky-linux-gnueabi

to qt5.sh in the "/opt/poky/1.7/sysroots/x86_64-pokysdk-linux/environment-setup.d" directory. This was a good chance in that qmake build correctly and Qt Creator is happy when launched form the command line using qtcreator.sh.

But, when attempting to launch qtcreator.sh form a ".desktop" file/launcher I was finding that my environment variables within Qt Creator where not being set properly for the OE compiler settings.

 

So, in order to get a ".desktop" launcher to work I had to make modifications to the qtcreator.sh file.

Add the following lines above the "#! /bin/sh" in qtcreator.sh located in your "~/Qt5.3.2/Tools/QtCreator/bin". It is important to note that you need to use "." instead of "source", since using "source" does not appear to work with ".desktop" files. Note, the paths are a direct copy from the "qt5.sh" file with the addition of some quotes, the quotes are important creator will not launch without them (all $ variables need to have quotes around them").

So, in order to get a ".desktop" launcher to work I had to make the following modifications to the qtcreator.sh file:

. /opt/poky/1.7/environment-setup-cortexa9hf-vfp-neon-poky-linux-gnueabi

 

# Start - Additions for the yocto distribution of Qt

export PATH=$OECORE_NATIVE_SYSROOT/usr/bin/qt5:$PATH

export OE_QMAKE_CFLAGS="$CFLAGS"

export OE_QMAKE_CXXFLAGS="$CXXFLAGS"

export OE_QMAKE_LDFLAGS="$LDFLAGS"

export OE_QMAKE_CC="$CC"

export OE_QMAKE_CXX="$CXX"

export OE_QMAKE_LINK="$CXX"

export OE_QMAKE_AR="$AR"

export QT_CONF_PATH="$OECORE_NATIVE_SYSROOT"/usr/bin/qt5/qt.conf

export OE_QMAKE_LIBDIR_QT=`qmake -query QT_INSTALL_LIBS`

export OE_QMAKE_INCDIR_QT=`qmake -query QT_INSTALL_HEADERS`

export OE_QMAKE_MOC="$OECORE_NATIVE_SYSROOT"/usr/bin/qt5/moc

export OE_QMAKE_UIC="$OECORE_NATIVE_SYSROOT"/usr/bin/qt5/uic

export OE_QMAKE_RCC="$OECORE_NATIVE_SYSROOT"/usr/bin/qt5/rcc

export OE_QMAKE_QDBUSCPP2XML="$OECORE_NATIVE_SYSROOT"/usr/bin/qt5/qdbuscpp2xml

export OE_QMAKE_QDBUSXML2CPP="$OECORE_NATIVE_SYSROOT"/usr/bin/qt5/qdbusxml2cpp

export OE_QMAKE_QT_CONFIG=`qmake -query QT_INSTALL_LIBS`/qt5/mkspecs/qconfig.pri

export QMAKESPEC=`qmake -query QT_INSTALL_LIBS`/mkspecs/linux-oe-g++

# End - Additions for the yocto distribution of Qt

 

#! /bin/sh

 

For those interested in creating a ".desktop" file create a file something like "qtcreator.desktop", open the file in a text editor and insert the following information:

[Desktop Entry]

Version=5.3.2

Name=Qt5 Creator

Comment=Qt5 Creator 5.3.2

Exec=~/Qt5.3.2/Tools/QtCreator/bin/qtcreator.sh

Icon=~/Qt5.3.2/Tools/QtCreator/bin/qtcreator.png

Terminal=false

Type=Application

Categories=Development;Application;

 

Remember to set the proper path to "qtcreator.sh". Also you can fetch a Qt Creator png (with transparency) off the net and use a path to this image to create a nice image on you desktop/launcher.

 

There might be an easier way, but this is what worked for me.

 

Regards,

Ossian

Outcomes