Gionata Benelli
Gionata Benelli

Reputation: 407

Petalinux - Multiple Source File application

I'm pretty new to the 2020.2 version of Petalinux and I'm trying to create a simple application inside my project using the C template.

After creating the helloworld-app using the command:

petalinux-create -t apps --template c --name helloworld-app

After enabling the default application and building it successfully,I tried to add some functionality by creating a new directory under helloworld-app/files called Ethernet, containing 2 files Etherent.c and Ethernet.h

Finally, I added the Ethernet.o object to the list inside the auto-generated Makefile for the module, I also added a VPATH for simplicity.

Unfortunately the build fails, in fact bitbake tells me that no rule for the object Ethernet.o is specified.

  1. How can I modify the makefile in order for this simple code to compile?
  2. I can edit the .bb file? I would like not to, since in that way i would have to specify every src file...

Thank you for the support! Ethernet.c:

#include "Ethernet.h"
//some C code

helloworld-app.c:

#include <stdio.h>
#include "Ethernet/Ethernet.h"

//some C code

Makefile:

APP = helloworld-app

VPATH=Ethernet

# Add any other object files to this list below
APP_OBJS = helloworld-app.o Ethernet.o

all: build

build: $(APP)

$(APP): $(APP_OBJS)
    $(CC) -o $@ $(APP_OBJS) $(LDFLAGS) $(LDLIBS)
clean:
    rm -f $(APP) *.o

Below I included the output of the petalinux-build -c helloworld-app command: enter image description here

Upvotes: 0

Views: 1475

Answers (1)

Gionata Benelli
Gionata Benelli

Reputation: 407

A simple solution, but really cumbersome if the number of files increases, is to simply add the path to the source files to the variable SRC_URI inside the .bb file. I will leave this question without an accepted answer, waiting for a more sustainable solution. Thanks to everyone!

Upvotes: 0

Related Questions