|
|
| (21 intermediate revisions by 4 users not shown) |
| Line 1: |
Line 1: |
| [[Category:Developers]] | | [[Category:Developers]] |
| = Using QtCreator =
| | Creating an AsteroidOS app can be fun and rewarding. Creating an app requires the installation of the Software Development Kit (SDK) as described in [[Installing the SDK]] and/or installing the entire bitbake environment as described in [[Building AsteroidOS]]. Note that the process of creating a watchface is a different (and somewhat easier) process documented in [[Creating a Watchface]]. Many new users start by customizing an existing watchface before graduating to creating their own watchfaces and perhaps ultimately creating their own apps. |
| QtCreator is an integrated development environment for making Qt QML applications.
| |
|
| |
|
| == Getting the Cross Compilation Toolchain == | | === Build methods === |
| | There are three ways that developers create or modify applications: |
|
| |
|
| The app creation process of AsteroidOS needs a Software Development Kit generated by OpenEmbedded. You can either grab a prebuilt SDK for the nightlies [https://release.asteroidos.org/nightlies/sdk/oecore-x86_64-armv7vehf-neon-toolchain-nodistro.0.sh here] and install it on your system or you can build it yourself as follows:
| | # [[OpenEmbedded|Build with <code>devtool</code> or <code>bitbake</code>]] ('''recommended''') |
| | # [[Build from the command line]] |
| | # [[Build with QtCreator]] |
|
| |
|
| == Building the Cross Compilation Toolchain ==
| | What AsteroidOS developers use is <code>devtool</code> and <code>bitbake</code>, but setting up the entire <code>bitbake</code> environment can be somewhat daunting to beginners and building the entire AsteroidOS uses a lot of resources (time, memory and disk space). The other two methods are a quick and low-resource (in terms of time, memory and disk space required) ways to begin, but have limitations. For this reason, it's recommended to move to using <code>bitbake</code> as soon as practical to avoid these limitations and their corresponding frustrations. |
|
| |
|
| Alternatively you can also build the toolchain from source. If you’ve already got an OpenEmbedded build directory via the [[Building AsteroidOS]] page, cd to that directory. Else, create one with:
| | {| class="wikitable" |
| | |+ Build method table |
| | |- |
| | ! Method !! Advantages !! Drawbacks |
| | |- |
| | | command line || simple, fast, easy to set up || doesn't always create <code>.ipk</code> file, doesn't automatically handle dependencies |
| | |- |
| | | QtCreator || good for GUI development || difficult to set up, doesn't create <code>.ipk</code> file |
| | |- |
| | | <code>devtool</code> || creates <code>.ipk</code> file, correctly handles dependencies || relatively complex to set up, can be slow to compile |
| | |} |
|
| |
|
| === Build without containers ===
| | Having a properly constructed <code>.ipk</code> file not only allows simplified installation on the watch, but also includes dependencies (other libraries on which the code might depend). All of the <code>.ipk</code> files on our [https://release.asteroidos.org/nightlies/ipk/ nightly builds] are created using the OpenEmbedded tool <code>bitbake</code>. |
|
| |
|
| <pre>
| | The command-line version build of <code>asteroid-helloworld</code> creates a simple installable <code>.ipk</code> file by adding build instructions for that directly to the [https://github.com/AsteroidOS/asteroid-helloworld/blob/a3908a7c7d13491b189ca4c0767c43ed24ce0271/CMakeLists.txt#L31C1-L45C15 CMakeLists.txt file]. This works as a temporary fix, but is generally '''not''' done for AsteroidOS projects because it would interfere with the way <code>bitbake</code> builds and because it does not automatically include dependencies, as mentioned above. |
| git clone https://github.com/AsteroidOS/asteroid
| |
| cd asteroid/
| |
| </pre>
| |
| | |
| Then, build the cross compilation toolchain with:
| |
| | |
| <pre>
| |
| source ./prepare-build.sh dory
| |
| bitbake meta-toolchain-qt5
| |
| </pre> | |
| | |
| === Build with containers===
| |
| | |
| Assuming you already prepared a docker or podman build environment like in: [[Building AsteroidOS]].
| |
| | |
| <pre>
| |
| sudo docker rm -f asteroidos-toolchain
| |
| sudo docker run -it \
| |
| --name asteroidos-toolchain \
| |
| -v /etc/passwd:/etc/passwd:ro \
| |
| -u "$(id -u):$(id -g)" \
| |
| -v "$HOME/.gitconfig:/$HOME/.gitconfig:ro" \
| |
| -v "$(pwd):/asteroid" asteroidos-toolchain \
| |
| bash -c "source ./prepare-build.sh dory && bitbake meta-toolchain-qt5"
| |
| </pre>
| |
| | |
| or
| |
| | |
| <pre>
| |
| podman run --rm -it \
| |
| -v "$(pwd)":/asteroid:z \
| |
| --userns keep-id asteroidos-toolchain \
| |
| bash -c "source ./prepare-build.sh dory && bitbake meta-toolchain-qt5"
| |
| </pre> | |
| | |
| ==Install the SDK ==
| |
| | |
| If you downloaded a prebuilt SDK, run the downloaded script. If you followed the previous steps, this will have generated the same installation script in <code>tmp-glibc/deploy/sdk/</code>, you can run it as follows:
| |
| | |
| <pre>
| |
| ./tmp-glibc/deploy/sdk/oecore-x86_64-armv7vehf-neon-toolchain-nodistro.0.sh | |
| </pre>
| |
| | |
| This script will install the cross-compiler and ARM libraries in <code>/usr/local/oecore-x86_64</code> by default, along with a script that needs to be sourced before every build. If you want to build a simple project via the terminal, this can be done like that:
| |
| | |
| <pre>
| |
| source /usr/local/oecore-x86_64/environment-setup-armv7vehf-neon-oe-linux-gnueabi
| |
| cmake -B build
| |
| cmake --build build
| |
| </pre>
| |
| | |
| ==Configure QtCreator for cross compilation==
| |
| | |
| Before running QtCreator you must run the previously mentioned script:
| |
| | |
| <code>
| |
| source /usr/local/oecore-x86_64/environment-setup-armv7vehf-neon-oe-linux-gnueabi
| |
| qtcreator
| |
| </code>
| |
| One other environment variable needs to be set to work seamlessly with AsteroidOS:
| |
| | |
| <code>
| |
| export CMAKE_PROGRAM_PATH=/usr/local/oecore-x86_64/sysroots/armv7vehf-neon-oe-linux-gnueabi/usr/bin/
| |
| </code>
| |
| | |
| This can be done automatically by prepending <code>source /usr/local/oecore-x86_64/environment-setup-armv7vehf-neon-oe-linux-gnueabi</code> and the export command before <code>#!/bin/sh</code> in <code>/usr/bin/qtcreator.sh</code>
| |
| | |
| Now that you are in QtCreator go to <code>Tools</code> → <code>Options</code> → <code>Devices</code>
| |
| | |
| - Add a new Generic Linux Device.
| |
| - Name it "AsteroidOS Watch".
| |
| - Choose 192.168.2.15 as IP address.
| |
| - Use root as user.
| |
| - Choose Password authentication and leave the password field empty.
| |
| | |
| | |
| Under the <code>Kits</code> add a kit with the previously defined device:
| |
| - Set <code>Device type</code> to Generic Linux Device.
| |
| - Set the <code>Device</code> to AsteroidOS Watch.
| |
| - Set the sysroot to <code>/usr/local/oecore-x86_64/sysroots/armv7vehf-neon-oe-linux-gnueabi/</code>.
| |
| - In the CMake generator change the <code>Generator</code> to <code>Unix Makefiles</code>.
| |
| - Change <code>Qt version</code> to <code>None</code>.
| |
| - Change <code>C</code> compiler to <code><No compiler></code>.
| |
| - Change <code>C++</code> compiler to <code><No compiler></code>.
| |
| - Change <code>CMake Tool</code> to System CMake at /usr/local/oecore-x86_64/usr/bin/cmake
| |
| - Clear the <code>CMake Configuration</code> fields.
| |
| | |
| Note that if these steps are not done *in this order*, QtCreator will not let you change both the <code>C</code> compiler and <code>C++</code> compiler to <code><No compiler></code>. Specifically, setting Qt version to <code>None</code> must be done first.
| |
| | |
| = First app=
| |
| | |
| [https://github.com/AsteroidOS/asteroid-helloworld Asteroid-helloworld] can act as a cool QML demo app to make your first steps into AsteroidOS development easier. You can clone it, build it, install it and then modify it to follow your needs: | |
| | |
| <code>
| |
| git clone https://github.com/AsteroidOS/asteroid-helloworld
| |
| cd asteroid-helloworld/
| |
| source /usr/local/oecore-x86_64/environment-setup-armv7vehf-neon-oe-linux-gnueabi
| |
| qtcreator CMakeLists.txt
| |
| </code>
| |
| | |
| Try to build and deploy the app. If it wasn’t already installed, a new icon should have already appeared on asteroid-launcher.
| |
| | |
| You can start by modifying occurrences of “asteroid-helloworld” to your app’s name. Then you can change the *.desktop file which describes the icon on the apps launcher. Then modify main.qml to describe your UI. To get started with QML development you can read the [http://doc.qt.io/qt-5/qml-tutorial.html official tutorial].
| |
| | |
| ==Deploy an app from QtCreator==
| |
| | |
| Open the project as described in the previous sections.
| |
| | |
| - Click on the <code>Projects</code> button on the left sidebar.
| |
| - Under the <code>Build & Run</code> section click on the <code>Run</code> configuration. This opens all run settings.
| |
| - Scroll down to the <code>Run</code> settings.
| |
| | |
| Change the following <code>Run</code> settings:
| |
| - Set the <code>Run configuration</code> to <code>Custom Executable (on AsteroidOS Watch)</code>.
| |
| - Set the <code>Remote executable</code> to <code>invoker</code>. Add the <code>--single-instance --type=qtcomponents-qt5 /usr/local/bin/asteroid-helloworld</code> command line arguments.
| |
| | |
| Change the following <code>Environment</code> variables:
| |
| - Add <code>XDG_RUNTIME_DIR</code> and set its value to <code>/run/user/1000</code>. So that the invoker works under the root user.
| |
| - (Optional) Add <code>QT_WAYLAND_DISABLE_WINDOWDECORATION</code> with value <code>1</code>. To make the app full screen and hide the titlebar.
| |
| | |
| Your app should now be able to run from the application when you click the start button in the bottom left sidebar.
| |
| | |
| =Tips and tricks=
| |
| | |
| If you want to start your app from the command line, open a shell with [[SSH]], connect to ceres and use invoker:
| |
| | |
| <code>
| |
| invoker --type=qtcomponents-qt5 /usr/bin/asteroid-stopwatch
| |
| </code>
| |
| | |
| If you want to disable screen locking for easier development you can enable the demo mode of mce as root with:
| |
| | |
| <code>
| |
| mcetool -D on
| |
| </code>
| |
| =Troubleshooting=
| |
| | |
| The most common problems stem from not following these directions *exactly*. QtCreator helpfully tries to find compilers and set variables, but tends to set things up for the desktop as the target rather than AsteroidOS, so it often gets things wrong. The first step for troubleshooting with QtCreator is to go very carefully over each of the steps listed above and verify that they all match exactly.
| |
| | |
| ==Could not find a package configuration file provided by "ECM" ==
| |
| | |
| This is most often caused not having the environment variables set up as shown above under the topic of [[#Configure QtCreator for cross compilation | configuring QtCreator]]. The environment variables must all be set and then you must lauch <code>qtcreator</code> *in the same shell*. If you're not sure you've done this, an easy way to check is to try this command from the command line:
| |
| | |
| <code>
| |
| echo $CC
| |
| </code>
| |
| | |
| This should result in a line like this:
| |
| <code>
| |
| arm-oe-linux-gnueabi-gcc -march=armv7ve -mfpu=neon -mfloat-abi=hard --sysroot=/usr/local/oecore-x86_64/sysroots/armv7vehf-neon-oe-linux-gnueabi
| |
| </code>
| |
| | |
| If instead you get an empty line or some other non-ARM compiler, you may have made an error. One common error is to run the script directly instead of running it using <code>source</code> (or <code>.</code> on some Linux distributions). Another common error that causes the error about not finding ECM is if, in the Kit, the system CMake is used instead of the one for the AsteroidOS SDK.
| |
| | |
| = warning: The project contains C++ source files, but the currently active kit has no C++ compiler. The code model will not be fully functional.
| |
| | |
| This is not really an error but a warning. It's the result of having correctly chosen <code><No compiler></code> as per the instructions above and may safely be ignored.
| |
| | |
| == file INSTALL cannot find ... .desktop==
| |
| | |
| This is probably the result of a missing <code>CMAKE_PROGRAM_PATH</code>. As mentioned above, this must be set in order for a script that generates the desktop file to be correctly found and uses.
| |
| | |
| ==Remote process crashed==
| |
| | |
| One possibility is that your software has a bug, but another is that the <code>XDG_RUNTIME_DIR</code> is not set to <code>/run/user/1000</code> as mentioned above.
| |
| | |
| =="I fixed it but I get the same error!"==
| |
| | |
| This most often happens when something was originally wrong with the configuration, but a CMake scan was made and a possibly faulty Makefile from an earlier attempt still exists. To fix this, choose <code>Build</code> from the menu, and then <code>Rescan project</code>. This will run CMake again, ignoring existing cached values and forcing the recreation of a Makefile.
| |