How to know what version of cross compiler I am using on YOCTO?
Asked Answered
S

2

5

I am using Yocto project to build Linux distribution for my embedded board. After the build, I needed to use a cross compiler to compile applications from my host machine to be executed on my board.I have just entered the command bitbake meta-toolchain. Now I can compile code of applications that are intendent to run on my board on my host machine. I just want to know what is the name and what version of compiler I am using when doing so? how can I know this ? Is there a way to know more information about the toolchain which was build ?

Thank you.

Scleroderma answered 1/7, 2019 at 9:1 Comment(0)
P
6

Actually, since meta/recipes-devtools/gcc contains the available cross-compiler versions but no information about the one that is being built, you can check the current cross-compiler version by executing the following commands:

bitbake -e | grep "^GCCVERSION="

In order to check out the build system's toolchain configuration, you can refer to the variable TCMODE (it should be set in the distro configuration file; e.g. poky.conf), you can retrieve its actual value by issuing the commands below:

bitbake -e | grep "^TCMODE="

Then, you will find the GCCVERSION, along with the rest of the toolchain configuration variables, in poky/meta/conf/distro/include/tcmode-${TCMODE}.conf. Note that the variables inside the aforementioned file can be overwritten or reassigned in other configuration files such as conf/local.conf (that's why bitbake -e should be used to retrieve its real value instead).

In the case you are using the SDK

If you're using the Yocto-generated SDK, you can just execute <cross-compiler> --version, e.g.:

arm-poky-linux-gnueabi-gcc --version

To check the name of the cross-compiler that is being used in your build system, you can:

bitbake -e | grep "^export CC="

For further information refer to https://www.yoctoproject.org/docs/latest/mega-manual/mega-manual.html#dev-debugging-viewing-variable-values

Palais answered 2/7, 2019 at 8:23 Comment(4)
Yes I have build SDK to cross compile my application executing this command : ` bitbake meta-toolchain` To check the name of cross compiler I am using : bitbake -e | grep "^export CC=" It shows me : export CC="arm-poky-linux-gnueabi-gcc -march=armv7-a -marm -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a5 --sysroot=/home/gaston/linux4sam/poky/build-microchip/tmp/work/cortexa5hf-neon-poky-linux-gnueabi/defaultpkgname/1.0-r0/recipe-sysroot" To check the version of Cross cmpiler I taped this : arm-poky-linux-gnueabi-gcc --version but It tells me : arm-poky-linux-gnueabi-gcc: command not foundScleroderma
Have you installed the SDK properly? Have you sourced the SDK environment setup script? If so, just type ${CC} --versionPalais
It works now. I didn't source the SDK environment lately. Now i executed ${CC} --version And It shows me this : arm-poky-linux-gnueabi-gcc (GCC) 7.3.0 Copyright (C) 2017 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. I have noticed that it is the same version I have found in meta/recipes-devtools/gcc Thank you my friend.Scleroderma
Nice! You're welcome. I guess you're using Sumo; depending on your Yocto version there can be more than one gcc version available for building your image with!Palais
A
2

First, ideally write a recipe to build your application instead of building it by hand.

The compiler is GCC, so you can see what version it is by looking in meta/recipes-devtools/gcc.

Alkalify answered 1/7, 2019 at 9:42 Comment(2)
So when i need to compile a file, i should write, for exemple : " gcc -c main.cpp " instead of " g++ -c main.cpp " in the Makefile ?Scleroderma
g++ and gcc are just the C++ and C frontends for GCC.Alkalify

© 2022 - 2024 — McMap. All rights reserved.