Yocto Programming with CodeBlocks: Difference between revisions
(Created page with "<!-- Set release according to "release" parameter in URL and use RELEASE_DUNFELL_V1.7_DART-MX8M-MINI as default --> {{#vardefine:RELEASE_PARAM|{{#urlget:release}}}} <!-- --> {...") |
No edit summary |
||
Line 2: | Line 2: | ||
--> {{#vardefine:RELEASE_PARAM|{{#urlget:release}}}} <!-- | --> {{#vardefine:RELEASE_PARAM|{{#urlget:release}}}} <!-- | ||
--> {{#lst:Yocto_Platform_Customization|{{#var:RELEASE_PARAM|RELEASE_DUNFELL_V1.7_DART-MX8M-MINI}}}} <!-- | --> {{#lst:Yocto_Platform_Customization|{{#var:RELEASE_PARAM|RELEASE_DUNFELL_V1.7_DART-MX8M-MINI}}}} <!-- | ||
--> {{ #varexists:TOOLCHAIN_TARGET_CROSS_PREFIX | | {{ #vardefine:TOOLCHAIN_TARGET_CROSS_PREFIX | {{#var:TOOLCHAIN_TYPE}} }} }} <!-- | |||
--> {{PageHeader|{{#var:HARDWARE_NAME}} - Yocto Programming with Code::Blocks}} {{DocImage|category1={{#var:HARDWARE_NAME}}|category2=Yocto}} | --> {{PageHeader|{{#var:HARDWARE_NAME}} - Yocto Programming with Code::Blocks}} {{DocImage|category1={{#var:HARDWARE_NAME}}|category2=Yocto}} | ||
Line 40: | Line 41: | ||
= Configure Code::Blocks = | = Configure Code::Blocks = | ||
From the Menu, click on Settings and Compiler | |||
[[File:CodeBlock-MenuSettingsCompiler.jpg]] | |||
In the "Global Compiler Settings" window, click on Copy | |||
[[File:CodeBlock-GlobalCompilerSettings.jpg]] | |||
In the "Add new compiler" window, enter the new compiler's name and press OK | |||
[[File:CodeBlock-AddNewCompiler.jpg]] | |||
A popup windows will remind you to update the "Toolchain executables" page, just press OK. | |||
Click on the "Toolchain executables" tab and populate the fields according your Yocto toolchain. | |||
Assuming you followed the default instruction in Variscite's {{Varlink2|Yocto Toolchain installation|{{#var:RELEASE_LINK}}}} guide, the expected settings are | |||
* Compiler's installation directory: {{#var:TOOLCHAIN_HOST_SYSROOT_LOCATION}}/usr/bin/{{#var:TOOLCHAIN_TARGET_CROSS_PREFIX}} | |||
* C compiler: {{#var:TOOLCHAIN_TARGET_CROSS_PREFIX}}-gcc | |||
* C++ compiler: {{#var:TOOLCHAIN_TARGET_CROSS_PREFIX}}-g++ | |||
* Linker for dynamic libs: {{#var:TOOLCHAIN_TARGET_CROSS_PREFIX}}-g++ | |||
* Linker for static libs: {{#var:TOOLCHAIN_TARGET_CROSS_PREFIX}}-ar | |||
* Debugger: GDB/CDB debugger: default | |||
* Resource compiler: <empty> | |||
* Make program: make | |||
[[File:CodeBlock-ToolchainExecutables.jpg]] | |||
Click on the "Additional Paths" tab and add a new directory, matching the Compiler's installation directory: | |||
{{#var:TOOLCHAIN_HOST_SYSROOT_LOCATION}}/usr/bin/{{#var:TOOLCHAIN_TARGET_CROSS_PREFIX}} | |||
[[File:CodeBlock-AdditionalPaths.jpg]] | |||
then press OK. | |||
Code::Blocks is not able to detect Yocto toolchain enviroment settings and part of the . | |||
To optimize the compilation, click on the "Compiler settings" tab and then on the "Other compiler options" tab, finally add the right options. | |||
[[File:CodeBlock-OtherCompilerOptions.jpg]] | |||
{{#varexists:TOOLCHAIN_COMPILER_OPTIONS| | |||
Assuming you followed the default instruction in Variscite's {{Varlink2|Yocto Toolchain installation|{{#var:RELEASE_LINK}}}} guide, the expected settings are | |||
{{#var:TOOLCHAIN_COMPILER_OPTIONS}} | |||
|}} | |||
If unsure, you can get the right options running | |||
$ source {{#var:TOOLCHAIN_LOCATION}}{{#ifeq: {{#var:SOC_SERIES}}|imx8|<br>$ export LDFLAGS=|}} | |||
$ echo $CXX | cut -d' ' -f2- |
Revision as of 20:03, 16 January 2022
Code::Blocks is a free C/C++ IDE built around a plugin framework, designed to be very extensible and fully configurable.
This guide demonstrates how to create and debug a C++ application using Code::Blocks on the DART-MX8M-MINI.
Create your rootfs with Code::Blocks debug support
Debugging with Code::Blocks requires your preferred SSH server (openssh, dropbear, etc), gdb, and gdbserver installed on the target device. Append the following to the conf/local.conf file in your Yocto build directory:
EXTRA_IMAGE_FEATURES = " \ tools-debug \ ssh-server-dropbear \ "
Now bitbake your image.
Setup Host Computer Environment
Please follow the steps below to prepare a fresh Ubuntu 20.04 installation for Code::Blocks debugging:
Install Dependencies
$ sudo apt-get -y update $ sudo apt-get -y install build-essential gdb gdb-multiarch git
Install Code::Blocks
$ sudo apt install codeblocks codeblocks-contrib
Install Yocto Toolchain
A toolchain is necessary for cross compiling applications. To install the toolchain, follow Variscite's Yocto Toolchain installation guide.
Configure Code::Blocks
From the Menu, click on Settings and Compiler
In the "Global Compiler Settings" window, click on Copy
In the "Add new compiler" window, enter the new compiler's name and press OK
A popup windows will remind you to update the "Toolchain executables" page, just press OK.
Click on the "Toolchain executables" tab and populate the fields according your Yocto toolchain.
Assuming you followed the default instruction in Variscite's Yocto Toolchain installation guide, the expected settings are
- Compiler's installation directory: /opt/fslc-xwayland/3.1/sysroots/x86_64-fslcsdk-linux/usr/bin/aarch64-fslc-linux
- C compiler: aarch64-fslc-linux-gcc
- C++ compiler: aarch64-fslc-linux-g++
- Linker for dynamic libs: aarch64-fslc-linux-g++
- Linker for static libs: aarch64-fslc-linux-ar
- Debugger: GDB/CDB debugger: default
- Resource compiler: <empty>
- Make program: make
Click on the "Additional Paths" tab and add a new directory, matching the Compiler's installation directory:
/opt/fslc-xwayland/3.1/sysroots/x86_64-fslcsdk-linux/usr/bin/aarch64-fslc-linux
then press OK.
Code::Blocks is not able to detect Yocto toolchain enviroment settings and part of the .
To optimize the compilation, click on the "Compiler settings" tab and then on the "Other compiler options" tab, finally add the right options.
Assuming you followed the default instruction in Variscite's Yocto Toolchain installation guide, the expected settings are
-mcpu=cortex-a53+crc+crypto -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/opt/fslc-xwayland/3.1/sysroots/aarch64-fslc-linux
If unsure, you can get the right options running
$ source /opt/fslc-xwayland/3.1/environment-setup-aarch64-fslc-linux
$ export LDFLAGS= $ echo $CXX | cut -d' ' -f2-