gstreamerpetalinux

Error compiling gstreamer app in petalinux


I'm trying to compile a custom gstreamer app in petalinux with the next header files:

#include <stdlib.h>
#include <string.h>
#include <gst/gst.h>
#include <gio/gio.h>

The petalinux project already has the sysroot library sources populated after run:

petalinux-build --sdk
petalinux-package --sysroot

But compiling the app (petalinux-build -c myapp) I've got the next error:

| myapp.c:25:10: fatal error: gst/gst.h: No such file or directory
|  #include <gst/gst.h>
|           ^~~~~~~~~~~
| compilation terminated.

The make file is:

APP = myapp

# Add any other object files to this list below
APP_OBJS = myapp.o

all: build

build: $(APP)

$(APP): $(APP_OBJS)
    $(CC) $(LDFLAGS) -o $@ $(APP_OBJS) $(LDLIBS)

clean:
    -rm -f $(APP) *.elf *.gdb *.o

%.o : %.c
    $(CC) -c $(CFLAGS) -o $@ $< $(shell pkg-config --cflags --libs gstreamer-1.0 glib-2.0)

And the recipe:

#
# This file is the myapp recipe.
#

SUMMARY = "Simple myapp application"
SECTION = "PETALINUX/apps"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"

SRC_URI = "file://myapp .c \
       file://Makefile \
          "

S = "${WORKDIR}"

do_compile() {
         oe_runmake
}

do_install() {
         install -d ${D}${bindir}
         install -m 0755 myapp ${D}${bindir}

Does anyone have an idea what I'm missing and how to add correctly the gstreamer paths for compilation?

EDIT

As suggested I added the DEPENDS line in the recipe:

#
# This file is the myapp recipe.
#

SUMMARY = "Simple myapp application"
SECTION = "PETALINUX/apps"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"

SRC_URI = "file://myapp .c \
       file://Makefile \
          "

S = "${WORKDIR}"

DEPENDS = "glib-2.0 gstreamer1.0"
RDEPENDS_${PN} = "gstreamer1.0-plugins-base gstreamer1.0-plugins-good"

do_compile() {
         oe_runmake
}

do_install() {
         install -d ${D}${bindir}
         install -m 0755 myapp ${D}${bindir}

But unfortunately still giving same error...any ideas what could be wrong/missing?

Thanks in advance.


Solution

  • I finally got it working, what I've done is instead to use the makefile to compile , is to use the recipe and more importantly to add inherit pkgconfig line, in order to force to populate sysroot during compilation, this is the final working recipe, hope it can help to someone else with same issue:

        #
        # This file is the myapp recipe.
        #
    
        SUMMARY = "Simple myapp application"
        SECTION = "PETALINUX/apps"
        LICENSE = "MIT"
        LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
    
        SRC_URI = "file://myapp .c \
               file://Makefile \
                  "
    
        S = "${WORKDIR}"
    
        DEPENDS = "glib-2.0 gstreamer1.0"
        RDEPENDS_${PN} = "gstreamer1.0-plugins-base gstreamer1.0-plugins-good"
    
        inherit pkgconfig 
    
        do_compile() {
                 ${CC} ${WORKDIR}/myapp.c -o myapp ${CFLAGS} ${LDFLAGS} `pkg-config --cflags --libs gstreamer-1.0` 
        }
    
        do_install() {
                 install -d ${D}${bindir}
                 install -m 0755 myapp ${D}${bindir}
        }