- Create an application using following
command.
petalinux-create -t apps --template c -n sampleapp --enable
- Modify the file <plnx-proj-root>/project-spec/meta-user/recipes-apps/sampleapp/sampleapp.bb
as below:
#
# This file is the sampleapp recipe.
#
SUMMARY = "Simple sampleapp application"
SECTION = "PETALINUX/apps"
LICENSE = "MIT"
LIC_FILES_CHKSUM =
"file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
SRC_URI = "file://sampleapp.c \
"
S = "${WORKDIR}"
DEPENDS = " sample"
do_compile() {
${CC} ${CFLAGS} ${LDFLAGS} -o testsamplelib testsamplelib.c -lsample
}
do_install() {
install -d ${D}${bindir}
install -m 0755 sampleapp ${D}${bindir}
}
FILES_${PN} += "sampleapp"
- Edit the file project-spec/meta-user/recipes-apps/sampleapp/files/sampleapp.c.
#include <stdio.h>
#include <SAMPLE/libsample.h>
int main(int argc, char **argv)
{
printf("Hello World!\n");
samplelib();
return 0;
}
- Build the application using the following
command:
petalinux-build -c sampleapp
- Boot the newly created system image.
- Run your user application on the target system console. For
example, to run user application sampleapp:
# sampleapp
- Confirm that the result of the application is as expected.