Add Yocto SDK with QT5 to QT Creator: Difference between revisions
Mschmoeller (talk | contribs) |
Mschmoeller (talk | contribs) |
||
(6 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
The following instructions are based on '''DHCOM STM32MP1''' computer on module and Yocto version " | The following instructions are based on '''DHCOM STM32MP1''' computer on module and Yocto version "dunfell" | ||
__TOC__ | __TOC__ | ||
Line 13: | Line 13: | ||
== Download and install the SDK package == | == Download and install the SDK package == | ||
Get the [https://www.dropbox.com/s/ | Get the [https://www.dropbox.com/s/2siubx9l9lxbkxj/20211026-dhlinux-glibc-x86_64-dh-image-demo-cortexa7t2hf-neon-vfpv4-toolchain-nodistro.0.zip?dl=0 QT5 SDK for STM32mp1] | ||
Unpack the archive and install the toolchain. | Unpack the archive and install the toolchain. | ||
Line 46: | Line 46: | ||
Add a new kit selecting your new Qt5 version and compiler and setting the sysroot to /opt/dhlinux/nodistro.0/sysroots/cortexa7t2hf-neon-vfpv4-dhlinux-linux-gnueabi and leave the Qt mkspec empty. | Add a new kit selecting your new Qt5 version and compiler and setting the sysroot to /opt/dhlinux/nodistro.0/sysroots/cortexa7t2hf-neon-vfpv4-dhlinux-linux-gnueabi and leave the Qt mkspec empty. | ||
Then select your device | |||
[[Image:Qtcreator-add-kit.jpg|850px]] | [[Image:Qtcreator-add-kit.jpg|850px]] | ||
If there is a warning/error shown, please click apply between each step | If there is a warning/error shown, please click apply between each step. | ||
There is one last point. The SDK comes with an environment-setup which sets some variables that are needed if you want to use the toolchain. There are two ways to get this environment into Qt Creator: | |||
* The first way is rather simple: Open a shell and source the environment-setup script (in the example <tt>/opt/dhlinux/nodistro.0/environment-setup-cortexa7t2hf-neon-vfpv4-dhlinux-linux-gnueabi</tt>). After that start Qt Creator in the same shell session. If you want to use another toolchain, you have start a new shell session, source the corresponding environment-setup and start QtCreator from there. | |||
* The other possible way is bit more complicated, but in return it is possible to change the toolchain without restarting Qt Creator: In the settings of the kit there is a button for setting the environment of this kit ("Change"-button right of "Environment"). When this button is pressed, a window for editing text opens. There you can set environment variables by the schema <variable>=<value>, one variable can be set per line. You cannot simply copy the setup script, because at the script the shell is called and other variables are referenced which isn't supported by Qt Creator. It is also possible that the setup script imports additional scripts from the "environment-setup.d" directory of each sysroot. <br /> So you have to source the setup script and look what variables have been set and write them and their respective values into the window. <br /> If you want to use another toolchain, than you can change the used kit. An example for configuring the environment of a kit is inside the collapsible box. | |||
<div class="toccolours mw-collapsible mw-collapsed" style="overflow:auto;"> | |||
<div style="font-weight:bold;">Example for setting the environment variables at the kit</div> | |||
<div class="mw-collapsible-content"> | |||
/opt/dhlinux/nodistro.0/environment-setup-cortexa7t2hf-neon-vfpv4-dhlinux-linux-gnueabi: | |||
<tt># Check for LD_LIBRARY_PATH being set, which can break SDK and generally is a bad practice | |||
# http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html#AEN80 | |||
# http://xahlee.info/UnixResource_dir/_/ldpath.html | |||
# Only disable this check if you are absolutely know what you are doing! | |||
if [ ! -z "$LD_LIBRARY_PATH" ]; then | |||
echo "Your environment is misconfigured, you probably need to 'unset LD_LIBRARY_PATH'" | |||
echo "but please check why this was set in the first place and that it's safe to unset." | |||
echo "The SDK will not operate correctly in most cases when LD_LIBRARY_PATH is set." | |||
echo "For more references see:" | |||
echo " http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html#AEN80" | |||
echo " http://xahlee.info/UnixResource_dir/_/ldpath.html" | |||
return 1 | |||
fi | |||
export SDKTARGETSYSROOT=/opt/dhlinux/nodistro.0/sysroots/cortexa7t2hf-neon-vfpv4-dhlinux-linux-gnueabi | |||
export PATH=/opt/dhlinux/nodistro.0/sysroots/x86_64-oesdk-linux/usr/bin:/opt/dhlinux/nodistro.0/sysroots/x86_64-oesdk-linux/usr/sbin:/opt/dhlinux/nodistro.0/sysroots/x86_64-oesdk-linux/bin:/opt/dhlinux/nodistro.0/sysroots/x86_64-oesdk-linux/sbin:/opt/dhlinux/nodistro.0/sysroots/x86_64-oesdk-linux/usr/bin/../x86_64-oesdk-linux/bin:/opt/dhlinux/nodistro.0/sysroots/x86_64-oesdk-linux/usr/bin/arm-dhlinux-linux-gnueabi:/opt/dhlinux/nodistro.0/sysroots/x86_64-oesdk-linux/usr/bin/arm-dhlinux-linux-musl:$PATH | |||
export PKG_CONFIG_SYSROOT_DIR=$SDKTARGETSYSROOT | |||
export PKG_CONFIG_PATH=$SDKTARGETSYSROOT/usr/lib/pkgconfig:$SDKTARGETSYSROOT/usr/share/pkgconfig | |||
export CONFIG_SITE=/opt/dhlinux/nodistro.0/site-config-cortexa7t2hf-neon-vfpv4-dhlinux-linux-gnueabi | |||
export OECORE_NATIVE_SYSROOT="/opt/dhlinux/nodistro.0/sysroots/x86_64-oesdk-linux" | |||
export OECORE_TARGET_SYSROOT="$SDKTARGETSYSROOT" | |||
export OECORE_ACLOCAL_OPTS="-I /opt/dhlinux/nodistro.0/sysroots/x86_64-oesdk-linux/usr/share/aclocal" | |||
export OECORE_BASELIB="lib" | |||
export OECORE_TARGET_ARCH="arm" | |||
export OECORE_TARGET_OS="linux-gnueabi" | |||
unset command_not_found_handle | |||
export CC="arm-dhlinux-linux-gnueabi-gcc -mthumb -mfpu=neon-vfpv4 -mfloat-abi=hard -mcpu=cortex-a7 --sysroot=$SDKTARGETSYSROOT" | |||
export CXX="arm-dhlinux-linux-gnueabi-g++ -mthumb -mfpu=neon-vfpv4 -mfloat-abi=hard -mcpu=cortex-a7 --sysroot=$SDKTARGETSYSROOT" | |||
export CPP="arm-dhlinux-linux-gnueabi-gcc -E -mthumb -mfpu=neon-vfpv4 -mfloat-abi=hard -mcpu=cortex-a7 --sysroot=$SDKTARGETSYSROOT" | |||
export AS="arm-dhlinux-linux-gnueabi-as " | |||
export LD="arm-dhlinux-linux-gnueabi-ld --sysroot=$SDKTARGETSYSROOT" | |||
export GDB=arm-dhlinux-linux-gnueabi-gdb | |||
export STRIP=arm-dhlinux-linux-gnueabi-strip | |||
export RANLIB=arm-dhlinux-linux-gnueabi-ranlib | |||
export OBJCOPY=arm-dhlinux-linux-gnueabi-objcopy | |||
export OBJDUMP=arm-dhlinux-linux-gnueabi-objdump | |||
export READELF=arm-dhlinux-linux-gnueabi-readelf | |||
export AR=arm-dhlinux-linux-gnueabi-ar | |||
export NM=arm-dhlinux-linux-gnueabi-nm | |||
export M4=m4 | |||
export TARGET_PREFIX=arm-dhlinux-linux-gnueabi- | |||
export CONFIGURE_FLAGS="--target=arm-dhlinux-linux-gnueabi --host=arm-dhlinux-linux-gnueabi --build=x86_64-linux --with-libtool-sysroot=$SDKTARGETSYSROOT" | |||
export CFLAGS=" -O2 -pipe -g -feliminate-unused-debug-types " | |||
export CXXFLAGS=" -O2 -pipe -g -feliminate-unused-debug-types " | |||
export LDFLAGS="-Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed" | |||
export CPPFLAGS="" | |||
export KCFLAGS="--sysroot=$SDKTARGETSYSROOT" | |||
export OECORE_DISTRO_VERSION="0.0.1" | |||
export OECORE_SDK_VERSION="nodistro.0" | |||
export ARCH=arm | |||
export CROSS_COMPILE=arm-dhlinux-linux-gnueabi- | |||
# Append environment subscripts | |||
if [ -d "$OECORE_TARGET_SYSROOT/environment-setup.d" ]; then | |||
for envfile in $OECORE_TARGET_SYSROOT/environment-setup.d/*.sh; do | |||
. $envfile | |||
done | |||
fi | |||
if [ -d "$OECORE_NATIVE_SYSROOT/environment-setup.d" ]; then | |||
for envfile in $OECORE_NATIVE_SYSROOT/environment-setup.d/*.sh; do | |||
. $envfile | |||
done | |||
fi</tt> | |||
There are additional scripts in the "environment-setup.d"-directories of the sysroots which are included at the main setup-script. These scripts have the following content: | |||
/opt/dhlinux/nodistro.0/sysroots/x86_64-oesdk-linux/environment-setup.d/cmake.sh: | |||
<tt>export OE_CMAKE_TOOLCHAIN_FILE="$OECORE_NATIVE_SYSROOT/usr/share/cmake/OEToolchainConfig.cmake" | |||
export OE_CMAKE_FIND_LIBRARY_CUSTOM_LIB_SUFFIX="`echo $OECORE_BASELIB | sed -e s/lib//`"</tt> | |||
/opt/dhlinux/nodistro.0/sysroots/x86_64-oesdk-linux/environment-setup.d/openssl.sh: | |||
<tt>export PATH=$OECORE_NATIVE_SYSROOT/usr/bin:$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 OE_QMAKE_STRIP=$STRIP | |||
export QT_CONF_PATH=$OECORE_NATIVE_SYSROOT/usr/bin/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/moc | |||
export OE_QMAKE_UIC=$OECORE_NATIVE_SYSROOT/usr/bin/uic | |||
export OE_QMAKE_RCC=$OECORE_NATIVE_SYSROOT/usr/bin/rcc | |||
export OE_QMAKE_QDBUSCPP2XML=$OECORE_NATIVE_SYSROOT/usr/bin/qdbuscpp2xml | |||
export OE_QMAKE_QDBUSXML2CPP=$OECORE_NATIVE_SYSROOT/usr/bin/qdbusxml2cpp | |||
export OE_QMAKE_QT_CONFIG=`qmake -query QT_INSTALL_LIBS`/mkspecs/qconfig.pri | |||
export OE_QMAKE_PATH_HOST_BINS=$OECORE_NATIVE_SYSROOT/usr/bin | |||
export QMAKESPEC=`qmake -query QT_INSTALL_LIBS`/mkspecs/linux-oe-g++</tt> | |||
/opt/dhlinux/nodistro.0/sysroots/x86_64-oesdk-linux/environment-setup.d/qt5.sh: | |||
<tt>export OPENSSL_CONF="$OECORE_NATIVE_SYSROOT/usr/lib/ssl-1.1/openssl.cnf"</tt> | |||
This results in the following environment configuration: | |||
[[File:Qtcreator-set-environment.png|1000px]] | |||
</div></div> |
Latest revision as of 12:59, 26 October 2021
The following instructions are based on DHCOM STM32MP1 computer on module and Yocto version "dunfell"
Prepairing your virtual machine
Get the Virtual Machine for Application Development.
Install the following package:
$ sudo apt-get install qtcreator qt5default
Download and install the SDK package
Get the QT5 SDK for STM32mp1
Unpack the archive and install the toolchain.
$ sh ./dhlinux-glibc-x86_64-meta-toolchain-qt5-cortexa7t2hf-neon-vfpv4-toolchain-nodistro.0.sh
Choose the installation directory (default: /opt/dhlinux/nodistro.0/).
The toolchain is now installed to your system.
Configure Qt Creator
Run QT Creator
In Qt Creator go to Tools > Options > Devices and add your Wandboard as a generic linux device.
go to Tools > Options > Build & Run and:
Add a new c++ compiler. Select your compiler: /opt/dhlinux/nodistro.0/sysroots/x86_64-oesdk-linux/usr/bin/arm-dhlinux-linux-gnueabi/arm-dhlinux-linux-gnueabi-g++
Add a new debugger. Select your debugger: /opt/dhlinux/nodistro.0/sysroots/x86_64-oesdk-linux/usr/bin/arm-dhlinux-linux-gnueabi/arm-dhlinux-linux-gnueabi-gdb
Add your Qt version by selecting the qmake located in /opt/dhlinux/nodistro.0/sysroots/x86_64-oesdk-linux/usr/bin/qmake
Add a new kit selecting your new Qt5 version and compiler and setting the sysroot to /opt/dhlinux/nodistro.0/sysroots/cortexa7t2hf-neon-vfpv4-dhlinux-linux-gnueabi and leave the Qt mkspec empty. Then select your device
If there is a warning/error shown, please click apply between each step.
There is one last point. The SDK comes with an environment-setup which sets some variables that are needed if you want to use the toolchain. There are two ways to get this environment into Qt Creator:
- The first way is rather simple: Open a shell and source the environment-setup script (in the example /opt/dhlinux/nodistro.0/environment-setup-cortexa7t2hf-neon-vfpv4-dhlinux-linux-gnueabi). After that start Qt Creator in the same shell session. If you want to use another toolchain, you have start a new shell session, source the corresponding environment-setup and start QtCreator from there.
- The other possible way is bit more complicated, but in return it is possible to change the toolchain without restarting Qt Creator: In the settings of the kit there is a button for setting the environment of this kit ("Change"-button right of "Environment"). When this button is pressed, a window for editing text opens. There you can set environment variables by the schema <variable>=<value>, one variable can be set per line. You cannot simply copy the setup script, because at the script the shell is called and other variables are referenced which isn't supported by Qt Creator. It is also possible that the setup script imports additional scripts from the "environment-setup.d" directory of each sysroot.
So you have to source the setup script and look what variables have been set and write them and their respective values into the window.
If you want to use another toolchain, than you can change the used kit. An example for configuring the environment of a kit is inside the collapsible box.
/opt/dhlinux/nodistro.0/environment-setup-cortexa7t2hf-neon-vfpv4-dhlinux-linux-gnueabi:
# Check for LD_LIBRARY_PATH being set, which can break SDK and generally is a bad practice # http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html#AEN80 # http://xahlee.info/UnixResource_dir/_/ldpath.html # Only disable this check if you are absolutely know what you are doing! if [ ! -z "$LD_LIBRARY_PATH" ]; then echo "Your environment is misconfigured, you probably need to 'unset LD_LIBRARY_PATH'" echo "but please check why this was set in the first place and that it's safe to unset." echo "The SDK will not operate correctly in most cases when LD_LIBRARY_PATH is set." echo "For more references see:" echo " http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html#AEN80" echo " http://xahlee.info/UnixResource_dir/_/ldpath.html" return 1 fi export SDKTARGETSYSROOT=/opt/dhlinux/nodistro.0/sysroots/cortexa7t2hf-neon-vfpv4-dhlinux-linux-gnueabi export PATH=/opt/dhlinux/nodistro.0/sysroots/x86_64-oesdk-linux/usr/bin:/opt/dhlinux/nodistro.0/sysroots/x86_64-oesdk-linux/usr/sbin:/opt/dhlinux/nodistro.0/sysroots/x86_64-oesdk-linux/bin:/opt/dhlinux/nodistro.0/sysroots/x86_64-oesdk-linux/sbin:/opt/dhlinux/nodistro.0/sysroots/x86_64-oesdk-linux/usr/bin/../x86_64-oesdk-linux/bin:/opt/dhlinux/nodistro.0/sysroots/x86_64-oesdk-linux/usr/bin/arm-dhlinux-linux-gnueabi:/opt/dhlinux/nodistro.0/sysroots/x86_64-oesdk-linux/usr/bin/arm-dhlinux-linux-musl:$PATH export PKG_CONFIG_SYSROOT_DIR=$SDKTARGETSYSROOT export PKG_CONFIG_PATH=$SDKTARGETSYSROOT/usr/lib/pkgconfig:$SDKTARGETSYSROOT/usr/share/pkgconfig export CONFIG_SITE=/opt/dhlinux/nodistro.0/site-config-cortexa7t2hf-neon-vfpv4-dhlinux-linux-gnueabi export OECORE_NATIVE_SYSROOT="/opt/dhlinux/nodistro.0/sysroots/x86_64-oesdk-linux" export OECORE_TARGET_SYSROOT="$SDKTARGETSYSROOT" export OECORE_ACLOCAL_OPTS="-I /opt/dhlinux/nodistro.0/sysroots/x86_64-oesdk-linux/usr/share/aclocal" export OECORE_BASELIB="lib" export OECORE_TARGET_ARCH="arm" export OECORE_TARGET_OS="linux-gnueabi" unset command_not_found_handle export CC="arm-dhlinux-linux-gnueabi-gcc -mthumb -mfpu=neon-vfpv4 -mfloat-abi=hard -mcpu=cortex-a7 --sysroot=$SDKTARGETSYSROOT" export CXX="arm-dhlinux-linux-gnueabi-g++ -mthumb -mfpu=neon-vfpv4 -mfloat-abi=hard -mcpu=cortex-a7 --sysroot=$SDKTARGETSYSROOT" export CPP="arm-dhlinux-linux-gnueabi-gcc -E -mthumb -mfpu=neon-vfpv4 -mfloat-abi=hard -mcpu=cortex-a7 --sysroot=$SDKTARGETSYSROOT" export AS="arm-dhlinux-linux-gnueabi-as " export LD="arm-dhlinux-linux-gnueabi-ld --sysroot=$SDKTARGETSYSROOT" export GDB=arm-dhlinux-linux-gnueabi-gdb export STRIP=arm-dhlinux-linux-gnueabi-strip export RANLIB=arm-dhlinux-linux-gnueabi-ranlib export OBJCOPY=arm-dhlinux-linux-gnueabi-objcopy export OBJDUMP=arm-dhlinux-linux-gnueabi-objdump export READELF=arm-dhlinux-linux-gnueabi-readelf export AR=arm-dhlinux-linux-gnueabi-ar export NM=arm-dhlinux-linux-gnueabi-nm export M4=m4 export TARGET_PREFIX=arm-dhlinux-linux-gnueabi- export CONFIGURE_FLAGS="--target=arm-dhlinux-linux-gnueabi --host=arm-dhlinux-linux-gnueabi --build=x86_64-linux --with-libtool-sysroot=$SDKTARGETSYSROOT" export CFLAGS=" -O2 -pipe -g -feliminate-unused-debug-types " export CXXFLAGS=" -O2 -pipe -g -feliminate-unused-debug-types " export LDFLAGS="-Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed" export CPPFLAGS="" export KCFLAGS="--sysroot=$SDKTARGETSYSROOT" export OECORE_DISTRO_VERSION="0.0.1" export OECORE_SDK_VERSION="nodistro.0" export ARCH=arm export CROSS_COMPILE=arm-dhlinux-linux-gnueabi- # Append environment subscripts if [ -d "$OECORE_TARGET_SYSROOT/environment-setup.d" ]; then for envfile in $OECORE_TARGET_SYSROOT/environment-setup.d/*.sh; do . $envfile done fi if [ -d "$OECORE_NATIVE_SYSROOT/environment-setup.d" ]; then for envfile in $OECORE_NATIVE_SYSROOT/environment-setup.d/*.sh; do . $envfile done fi
There are additional scripts in the "environment-setup.d"-directories of the sysroots which are included at the main setup-script. These scripts have the following content:
/opt/dhlinux/nodistro.0/sysroots/x86_64-oesdk-linux/environment-setup.d/cmake.sh:
export OE_CMAKE_TOOLCHAIN_FILE="$OECORE_NATIVE_SYSROOT/usr/share/cmake/OEToolchainConfig.cmake" export OE_CMAKE_FIND_LIBRARY_CUSTOM_LIB_SUFFIX="`echo $OECORE_BASELIB | sed -e s/lib//`"
/opt/dhlinux/nodistro.0/sysroots/x86_64-oesdk-linux/environment-setup.d/openssl.sh:
export PATH=$OECORE_NATIVE_SYSROOT/usr/bin:$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 OE_QMAKE_STRIP=$STRIP export QT_CONF_PATH=$OECORE_NATIVE_SYSROOT/usr/bin/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/moc export OE_QMAKE_UIC=$OECORE_NATIVE_SYSROOT/usr/bin/uic export OE_QMAKE_RCC=$OECORE_NATIVE_SYSROOT/usr/bin/rcc export OE_QMAKE_QDBUSCPP2XML=$OECORE_NATIVE_SYSROOT/usr/bin/qdbuscpp2xml export OE_QMAKE_QDBUSXML2CPP=$OECORE_NATIVE_SYSROOT/usr/bin/qdbusxml2cpp export OE_QMAKE_QT_CONFIG=`qmake -query QT_INSTALL_LIBS`/mkspecs/qconfig.pri export OE_QMAKE_PATH_HOST_BINS=$OECORE_NATIVE_SYSROOT/usr/bin export QMAKESPEC=`qmake -query QT_INSTALL_LIBS`/mkspecs/linux-oe-g++
/opt/dhlinux/nodistro.0/sysroots/x86_64-oesdk-linux/environment-setup.d/qt5.sh:
export OPENSSL_CONF="$OECORE_NATIVE_SYSROOT/usr/lib/ssl-1.1/openssl.cnf"
This results in the following environment configuration: