Skip to main content
Visitor II
May 7, 2021
Solved

[Solved] Problem tring to run gtk hello world (developper package) with bitbake (distribution package) : don't find how to properly source gtk.

  • May 7, 2021
  • 4 replies
  • 5713 views

Hello,

I'm trying to embed an app in the st-linux distribution. I mean that the goal is to have it compiled with bitbake and integrated in a custom st-image-weston.

I tried to use the gtk hello world example of Developper section (that run without problems) but with distribution package. ( https://wiki.st.com/stm32mpu/wiki/Getting_started/STM32MP1_boards/STM32MP157x-DK2/Develop_on_Arm%C2%AE_Cortex%C2%AE-A7/Create_a_simple_hello-world_application )

So I made a bitbake recipe but when I run it I get the error "error: gtk/gtk.h: No such file or directory".

But bitbake layers include gtk+3, when I run bitbake gtk+3 it is successful.

I tried adding gtk3 to compiling flags, DEPENDS, RDEPENDS, do_configure[depends] but nothing worked. The only thing that worked is sourcing the developper package sdk environnement setup, but it's weird. I'm a little of a beginner with bitbake and I didn't found how to make that developper package app work with the distribution package.

Here is my .bb file :

# Recipe created by recipetool
# This is the basis of a recipe and may need further editing in order to be fully functional.
# (Feel free to remove these comments when editing.)
 
# Unable to find any files that looked like license statements. Check the accompanying
# documentation and source headers and set LICENSE and LIC_FILES_CHKSUM accordingly.
#
# NOTE: LICENSE is being set to "CLOSED" to allow you to at least start building - if
# this is not accurate with respect to the licensing of the software being built (it
# will not be in most cases) you must specify the correct value before using this
# recipe for anything other than initial testing/development!
LICENSE = "CLOSED"
LIC_FILES_CHKSUM = ""
 
# No information for SRC_URI yet (only an external source tree was specified)
SRC_URI = ""
 
# NOTE: this is a Makefile-only piece of software, so we cannot generate much of the
# recipe automatically - you will need to examine the Makefile yourself and ensure
# that the appropriate arguments are passed in.
 
do_configure () {
	# Specify any needed configure commands here
	:
}
 
do_compile () {
	# You will almost certainly need to add additional arguments here
	#. /mnt/sda3/STM32MP15-Ecosystem-v3.0.0/Developer-Package/openstlinux-5.10-dunfell-mp1-21-03-31/SDK/environment-setup-cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi
 cd ${S}
	#oe_runmake
 ${CC} ${CFLAGS} ${LDFLAGS} gtk_hello_world.c -o gtk_hello_world
}
 
do_install () {
	# NOTE: unable to determine what to put here - there is a Makefile but no
	# target named "install", so you will need to define this yourself
	:
	#oe_runmake install
}

The source code is included with .bbappend file. I succesfully implemented a led blinking program and the following link into st-image-weston with bitbake but can't figure how to do in that case.

https://wiki.st.com/stm32mpu/wiki/How_to_cross-compile_with_the_Distribution_Package#Adding_a_-22hello_world-22_user_space_example

Any help would be appreciated. And thank you for reading that post.

    This topic has been closed for replies.
    Best answer by Jean-Marc B

    Hello @BJola.1​ 

    Thank you for your feedback.

    Could you try to update your recipe by adding this line:

    inherit pkgconfig

    and updating your compilation line by adding a call to pkg-config:

    ${CC} ${CFLAGS} ${LDFLAGS} gtk_hello_world.c -o gtk_hello_world `pkg-config --cflags --libs gtk+-3.0`

    This call to pkg-config should instruct the compiler where to find gtk sources when building your binary.

    Best regards,

    --JM

    4 replies

    ST Employee
    May 10, 2021

    Hi @BJola.1​ 

    The message error you get means the gtk+ environment is not yet available in your bitbake environment when building your recipe.

    I think you could add the line

    DEPENDS = "gtk+3"

    in your bitbake recipe as it depends on gtk+3 at build time.

    Best regards,

    --JM

    BJola.1Author
    Visitor II
    May 11, 2021

    Thank you for answering.

    I tried that, but it doesn't seem to be taken in account, the error message is the same.

    $ bitbake gtktest
    NOTE: Started PRServer with DBfile: /mnt/sda3/STM32MP15-Ecosystem-v3.0.0/Distribution-Package/openstlinux-5.10-dunfell-mp1-21-03-31/build-openstlinuxweston-stm32mp1/cache/prserv.sqlite3, IP: 127.0.0.1, PORT: 46211, PID: 6525
    Loading cache: 100% |##########################################################################################################################################################################################################| Time: 0:00:00
    Loaded 3767 entries from dependency cache.
    Parsing recipes: 100% |########################################################################################################################################################################################################| Time: 0:00:00
    Parsing of 2556 .bb files complete (2553 cached, 3 parsed). 3769 targets, 104 skipped, 0 masked, 0 errors.
    NOTE: Resolving any missing task queue dependencies
     
    Build Configuration:
    BB_VERSION = "1.46.0"
    BUILD_SYS = "x86_64-linux"
    NATIVELSBSTRING = "universal"
    TARGET_SYS = "arm-ostl-linux-gnueabi"
    MACHINE = "stm32mp1"
    DISTRO = "openstlinux-weston"
    DISTRO_VERSION = "3.1-snapshot-20210511"
    TUNE_FEATURES = "arm vfp cortexa7 neon vfpv4 thumb callconvention-hard"
    TARGET_FPU = "hard"
    DISTRO_CODENAME = "dunfell"
    ACCEPT_EULA_stm32mp1 = "1"
    GCCVERSION = "9.%"
    PREFERRED_PROVIDER_virtual/kernel = "linux-stm32mp"
    meta-python 
    meta-oe 
    meta-gnome 
    meta-initramfs 
    meta-multimedia 
    meta-networking 
    meta-webserver 
    meta-filesystems 
    meta-perl = "HEAD:5bba79488b7d393d2258d6e917f7bf7b0d7c4073"
    meta-st-stm32mp = "HEAD:7b55c34159fcfd57b4965f7aa9284200eea09d20"
    meta-qt5 = "HEAD:0d8eb956015acdea7e77cd6672d08dce18061510"
    meta-st-openstlinux = "HEAD:d6947f5a1898744aa15a96b68e8945f4f553175e"
    meta = "HEAD:72431ee8de5e3a53d259cebf420a7713ac9e1f14"
    workspace = "master:bfd0c9c71b2c9a22deab2643bf7c9d042d9c8ddf"
    meta-lidar-application = "master:a52e25f965ea476fccee813dc4fdde0d4e124f7b"
     
    Initialising tasks: 100% |#####################################################################################################################################################################################################| Time: 0:00:01
    Sstate summary: Wanted 110 Found 109 Missed 1 Current 1046 (99% match, 99% complete)
    NOTE: Executing Tasks
    NOTE: gtktest: compiling from external source tree /mnt/sda3/STM32MP15-Ecosystem-v3.0.0/Distribution-Package/openstlinux-5.10-dunfell-mp1-21-03-31/lidar-sources/gtktest
    ERROR: gtktest-1.0-r0 do_compile: Execution of '/mnt/sda3/STM32MP15-Ecosystem-v3.0.0/Distribution-Package/openstlinux-5.10-dunfell-mp1-21-03-31/build-openstlinuxweston-stm32mp1/tmp-glibc/work/cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi/gtktest/1.0-r0/temp/run.do_compile.6611' failed with exit code 1:
    gtk_hello_world.c:1:10: fatal error: gtk/gtk.h: No such file or directory
     1 | #include <gtk/gtk.h>
     | ^~~~~~~~~~~
    compilation terminated.
    WARNING: exit code 1 from a shell command.
     
    ERROR: Logfile of failure stored in: /mnt/sda3/STM32MP15-Ecosystem-v3.0.0/Distribution-Package/openstlinux-5.10-dunfell-mp1-21-03-31/build-openstlinuxweston-stm32mp1/tmp-glibc/work/cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi/gtktest/1.0-r0/temp/log.do_compile.6611
    Log data follows:
    | DEBUG: Executing python function externalsrc_compile_prefunc
    | NOTE: gtktest: compiling from external source tree /mnt/sda3/STM32MP15-Ecosystem-v3.0.0/Distribution-Package/openstlinux-5.10-dunfell-mp1-21-03-31/lidar-sources/gtktest
    | DEBUG: Python function externalsrc_compile_prefunc finished
    | DEBUG: Executing shell function do_compile
    | gtk_hello_world.c:1:10: fatal error: gtk/gtk.h: No such file or directory
    | 1 | #include <gtk/gtk.h>
    | | ^~~~~~~~~~~
    | compilation terminated.
    | WARNING: exit code 1 from a shell command.
    | ERROR: Execution of '/mnt/sda3/STM32MP15-Ecosystem-v3.0.0/Distribution-Package/openstlinux-5.10-dunfell-mp1-21-03-31/build-openstlinuxweston-stm32mp1/tmp-glibc/work/cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi/gtktest/1.0-r0/temp/run.do_compile.6611' failed with exit code 1:
    | gtk_hello_world.c:1:10: fatal error: gtk/gtk.h: No such file or directory
    | 1 | #include <gtk/gtk.h>
    | | ^~~~~~~~~~~
    | compilation terminated.
    | WARNING: exit code 1 from a shell command.
    | 
    ERROR: Task (/mnt/sda3/STM32MP15-Ecosystem-v3.0.0/Distribution-Package/openstlinux-5.10-dunfell-mp1-21-03-31/build-openstlinuxweston-stm32mp1/workspace/recipes/gtktest/gtktest.bb:do_compile) failed with exit code '1'
    NOTE: Tasks Summary: Attempted 3128 tasks of which 3127 didn't need to be rerun and 1 failed.
    NOTE: Writing buildhistory
    NOTE: Writing buildhistory took: 1 seconds
     
    Summary: 1 task failed:
     /mnt/sda3/STM32MP15-Ecosystem-v3.0.0/Distribution-Package/openstlinux-5.10-dunfell-mp1-21-03-31/build-openstlinuxweston-stm32mp1/workspace/recipes/gtktest/gtktest.bb:do_compile
    Summary: There was 1 ERROR message shown, returning a non-zero exit code.

    Exactly same message with and without. I tried with "=" and "+=" to be sure. I don't understand why bitbake dont include it. I also tried RDEPENDS and do_configure (but not sure how to use do_configure[depends]).

    Best regards.

    ST Employee
    May 11, 2021

    Hello @BJola.1​ 

    Thank you for your feedback.

    Could you try to update your recipe by adding this line:

    inherit pkgconfig

    and updating your compilation line by adding a call to pkg-config:

    ${CC} ${CFLAGS} ${LDFLAGS} gtk_hello_world.c -o gtk_hello_world `pkg-config --cflags --libs gtk+-3.0`

    This call to pkg-config should instruct the compiler where to find gtk sources when building your binary.

    Best regards,

    --JM

    BJola.1Author
    Visitor II
    May 12, 2021

    Tried with success, thank you !

    I tried something with pkg-config but it didn't worked as I didn't think to inherit.

    Thank you for your help.

    Best regards.

    ST Employee
    May 12, 2021

    Hi @BJola.1​ 

    I am glad you fixed your issue!

    Best Regards.

    --JM

    "To help community to find solutions, please click on "Select as Best" for reply which solved your issue or answered your question."