cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
sungrace
Observer
Observer
1,172 Views
Registered: ‎03-24-2018

Petalinux-2018.2 Custom Application Development

Hi all

 

I am trying to create a custom C++ application for Petalinux-2018.2.

I have many .cpp files and an Include directory.

 

I have followed instructions to create application development, but failed to understand this:

- where to add multiple .cpp files

- Make file additions / how to create Makefile for this type of application to create OBJ files

- how to include a directory, which have many .h files.

 

Can someone post a sample or point me in right direction.

 

Appreciate in advance.

0 Kudos
1 Reply
sandeepg
Moderator
Moderator
1,152 Views
Registered: ‎04-24-2017

Hi @sungrace,

 

You can use something like this

 

Makefile

APP = my-app

# Add any other object files to this list below
src=$(wildcard src/*.c) \
      $(wildcard src/video/*.c) \
      $(wildcard src/audio/*.c)

APP_OBJS = $(patsubst %.c,%.o,$(SRC))

all: build

build: $(APP)

$(APP): $(APP_OBJS)
	$(CC) -o $@ $(APP_OBJS) $(LDFLAGS) -Wl,-rpath-link, -Wl,-O1 -Wl,--hash-style=gnu -Wl,--allow-multiple-definition

%.o: %.c
	$(CC) -c $< $(CFLAGS) -o $@

clean:
	rm -f $(wildcard *.o) my-app

Recipe Method1:

#
# This file is the my-app recipe.
#

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

SRC_URI = " \
	   file://src/audio/source1.c \
	   file://src/audio/source2.c \
	   file://src/video/source3.c \
	   file://src/video/main.c \
	   file://Makefile \
	  "

S = "${WORKDIR}"

DEPENDS += " \
    library1 \
    library2 \
    "

do_compile() {
    oe_runmake
}

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

 

Recipe Method2:

#
# This file is the my-app recipe.
#

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

SRC_URI = " \
	   file://src \
	   file://Makefile \
	  "

S = "${WORKDIR}"

DEPENDS += " \
    library1 \
    library2 \
    "

do_compile() {
    oe_runmake
}

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

 

Thanks,
Sandeep
PetaLinux Yocto | Embedded SW Support

---------------------------------------------------------------------------
Don’t forget to Reply, Kudo, and Accept as Solution.
---------------------------------------------------------------------------
0 Kudos