Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
| Beide Seiten der vorigen RevisionVorhergehende ÜberarbeitungNächste Überarbeitung | Vorhergehende Überarbeitung | ||
| software:linux:yocto:getting_started_cpp [2020-03-31 11:15] – mlammerich | software:linux:yocto:getting_started_cpp [2024-04-23 13:08] (aktuell) – Moritz Lammerich | ||
|---|---|---|---|
| Zeile 1: | Zeile 1: | ||
| - | ======= Getting | + | ======= Getting |
| - | This guide will go through setting up a build environment and building an x86_64 image, and adding a small "hello world" application to it. First the application will be compiled using the [[ .:sdk | SDK ]], then it will be added to the image directly by creating a [[ .:recipes | recipe | + | This guide will go through setting up a build environment and building an x86_64 image, and adding a small "hello world" application to it. This page is a summary of the information from [[software:linux: |
| - | ===== Setting up the build environment | + | ===== Setting up the Build Environment |
| Create a directory in a suitable place to store everything related to this build. | Create a directory in a suitable place to store everything related to this build. | ||
| This guide will assume everything is in a directory called '' | This guide will assume everything is in a directory called '' | ||
| - | Next, clone '' | + | Next, clone '' |
| < | < | ||
| - | git clone -b yocto-3.0.2 | + | git clone -b kirkstone |
| </ | </ | ||
| Zeile 18: | Zeile 18: | ||
| </ | </ | ||
| - | Now we can initialize | + | Now we can initialize yocto using: |
| < | < | ||
| . poky/ | . poky/ | ||
| </ | </ | ||
| - | This will populate the build directory with all necessary files and give you access to '' | + | This will populate the build directory with all necessary files and give you access to '' |
| - | ==== Setting the machine | + | ==== Setting the Machine |
| Setting the machine tells bitbake what hardware to build for. This build will be a 64bit qemu image, so we can set the machine to '' | Setting the machine tells bitbake what hardware to build for. This build will be a 64bit qemu image, so we can set the machine to '' | ||
| Zeile 40: | Zeile 40: | ||
| The build environment is now set up. | The build environment is now set up. | ||
| - | ===== Building an image ===== | + | ===== Building an Image ===== |
| You can now build an image. This command will build a minimal image provided by '' | You can now build an image. This command will build a minimal image provided by '' | ||
| Zeile 55: | Zeile 55: | ||
| '' | '' | ||
| + | |||
| + | The default login is '' | ||
| ===== Creating a Hello World C++ Application ===== | ===== Creating a Hello World C++ Application ===== | ||
| Zeile 105: | Zeile 107: | ||
| </ | </ | ||
| - | ==== Optional: Verifying the application works ==== | + | ==== Optional: Verifying |
| This is an optional step to verify the application itself is built correctly before adding it to the image. | This is an optional step to verify the application itself is built correctly before adding it to the image. | ||
| Create a '' | Create a '' | ||
| Then execute '' | Then execute '' | ||
| - | applucation | + | application |
| Now there should be a '' | Now there should be a '' | ||
| After confirming it works, change back to '' | After confirming it works, change back to '' | ||
| Zeile 120: | Zeile 122: | ||
| make | make | ||
| ./hello | ./hello | ||
| - | cd ../build | + | cd ../../build |
| </ | </ | ||
| + | ===== Creating a Recipe for the application ===== | ||
| + | |||
| + | We use [[software: | ||
| + | < | ||
| + | devtool add ../ | ||
| + | </ | ||
| + | |||
| + | This should finish with a message similar to this one: | ||
| + | < | ||
| + | INFO: Recipe / | ||
| + | </ | ||
| + | |||
| + | This means devtool ran successfully and created a recipe at the specified location. | ||
| + | |||
| + | To test whether this recipe works, build it by running bitbake: | ||
| + | |||
| + | < | ||
| + | bitbake helloworld | ||
| + | </ | ||
| + | |||
| + | This should run without errors and print something like this when it's finished: | ||
| + | |||
| + | < | ||
| + | NOTE: Tasks Summary: Attempted 506 tasks of which 497 didn't need to be rerun and all succeeded. | ||
| + | </ | ||
| + | |||
| + | This means the package provided by the recipe was built successfully. | ||
| + | |||
| + | ===== Adding the Recipe to the Image ===== | ||
| + | |||
| + | Now that we have a recipe, we need to add it to the image to test it out. | ||
| + | Adding packages to recipes is done in '' | ||
| + | |||
| + | Edit '' | ||
| + | < | ||
| + | nano conf/ | ||
| + | </ | ||
| + | |||
| + | and add the following: | ||
| + | < | ||
| + | CORE_IMAGE_EXTRA_INSTALL += " | ||
| + | </ | ||
| + | |||
| + | Rebuild the image | ||
| + | < | ||
| + | bitbake core-image-minimal | ||
| + | </ | ||
| + | |||
| + | And run qemu | ||
| + | |||
| + | < | ||
| + | runqemu qemux86-64 nographic | ||
| + | </ | ||
| + | |||
| + | Log in as '' | ||
| + | < | ||
| + | root@qemux86-64: | ||
| + | Hello World! | ||
| + | </ | ||
| + | Congratulations! You have now developed your own C++ application and added it to a yocto image. | ||