AnsweredAssumed Answered

Helloworld sample for g2d

Question asked by Dan Searles on Apr 15, 2019
Latest reply on May 8, 2019 by Dan Searles

Hello,

Would anyone be able to supply a yocto recipe for a simple 'hello world' like application, that can access the G2D API?

 

I have such a recipe to build a simple gstreamer application, but so far, I have not been able to figure out how to include the depends/links that would allow including access to the G2D api.

Ex: here is the recipe for the gstreamer recipe/application that works fine:

gstreamer1.0-app_1.0.0.bb:

SMMARY = "GStreamer app-1.0.0"
DESCRIPTION = "Gstreamer app-1.0.0"
SECTION = "apps"

inherit pkgconfig

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

LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"

FILESEXTRAPATHS_prepend := "${THISDIR}/files:"

SRC_URI += " \
file://. \
"

inherit pkgconfig

do_compile() {
${CXX} ${WORKDIR}/gst-app_1.cpp -o gst-app_1 ${CXXFLAGS} ${LDFLAGS} `pkg-config --cflags --libs gstreamer-1.0`
}

do_install() {
install -d ${D}${bindir}/
install -m 0755 ${S}/gst-app_1 ${D}${bindir}/
}

FILES_${PN} += " \
${bindir}/ \
"

 

And in that dir, ./gstreamer1.0-app/gst-app_1.cpp contains:

#include <gst/gst.h>

 

int main(int argc, char *argv[]) {
GstElement *pipeline;
GstBus *bus;
GstMessage *msg;

 

/* Initialize GStreamer */
gst_init (&argc, &argv);

/* Build the pipeline */
pipeline = gst_parse_launch ("videotestsrc ! waylandsink name=mysink", NULL);

/* Start playing */
gst_element_set_state (pipeline, GST_STATE_PLAYING);

/* Wait until error or EOS */
bus = gst_element_get_bus (pipeline);
msg = gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE, GstMessageType(GST_MESSAGE_ERROR | GST_MESSAGE_EOS) );

/* Free resources */
if (msg != NULL)
gst_message_unref (msg);
gst_object_unref (bus);
gst_element_set_state (pipeline, GST_STATE_NULL);
gst_object_unref (pipeline);
return 0;
}

 

So instead of a gstreamer app, I would like to build an app source code file that uses G2D instead, like:

 

g2d-app_1.cpp:

 

#include "g2d.h"

int main(int argc, char *argv[]) {
void* handle;
g2d_open(&handle);

g2d_close(handle);
return 0;
}

 

So far, I just get errors that look like this:

Log data follows:
| DEBUG: Executing shell function do_compile
| /tmp/cciBbzfE.o: In function `main':
| ...gst-app_1.cpp:4: undefined reference to `g2d_open'
| ...gst-app_1.cpp:5: undefined reference to `g2d_close'
| collect2: error: ld returned 1 exit status
| WARNING: exit code 1 from a shell command.
| ERROR: Function failed: do_compile

 

Thanks

Outcomes