Yocto recipe for Hello World program compilation using a makefile.

Follow the below steps to create to Yocto recipe for hello world program compilation using a makefile.

  1. Create the Yocto recipe file

    Create a Hello World recipe in your custom layer.

    # vim recipes-hello/hello/hello_1.0.bb
    
    DESCRIPTION = "Simple hello world application"
    LICENSE = "MIT"
    LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
    
    SRC_URI = "file://hello_world.c \
               file://Makefile \
    "
    S = "${WORKDIR}"
    
    do_compile() {
        oe_runmake
    }
    
    do_install() {
        install -d ${D}${bindir}
        install -m 0755 hello ${D}${bindir}/
    }
    
    
  2. Create the Hello World program and makefile.

    Create hello world program and makefile in your recipe directory.

    # vim recipes-hello/hello/files/Makefile
    all:
    
        $(CC) -o hello_world hello_world.c
    
    clean:
        rm -f hello_world
    
    

    # vim recipes-hello/hello/files/hello_world.c
    #include<stdio.h>
    int main(){
    printf("Hello world \n");
    return 0;
    }
    
    
  3. Build Hello World recipe.

    Build the recipe using the below command.

    $ bitbake hello_world
    

Add comment


Security code
Refresh