how write .bb file for multiple file compilation?

cancel
Showing results for 
Search instead for 
Did you mean: 

how write .bb file for multiple file compilation?

1,585 Views
bhargavjayswal
Contributor II


Dear Expert,


I am using imx6 processor and wrote an application. To cross compile i am using yocto for that.

I have 4 files in different directory.

1. /home/Linux/NXP/XYZ/Embedded/read/read.c
2. /home/Linux/NXP/XYZ/Embedded/main/mainfun.c
3. /home/Linux/NXP/XYZ/Embedded/write/write.c
4. /home/Linux/NXP/XYZ/Embedded/config/config.c

and .bb file is located at

"/home/Linux/NXP/yocto/jethro/yocto/source/meta-mylayer/recipes-app/mainfun/mainfun.bb"

==> From mainfun.c i am calling different function which funcion defination are present inside write.c , config.c and 

        read.c

==>I am only come across single file compilation using yocto so can you please help how i write .bb file , how can i compile and generate "XYZ_app" exicutable.

Here i attached .bb file which i have written but not working

--------------------------------------------------------------------------------------------------------------------------------------------------------------

DESCRIPTION = "multiple file compilation"
PR = "r0"
LICENSE = "CLOSED"

SRC_URI += "file://home/Linux/NXP/XYZ/Embedded/ \
           "

S = "${WORKDIR}"

do_compile() {

    ${CC} ${CFLAGS} ${LDFLAGS} --static -c  ${WORKDIR}}/home/Linux/NXP/XYZ/Embedded/read/read.c
    ${CC} ${CFLAGS} ${LDFLAGS} --static -c  ${WORKDIR}}/home/Linux/NXP/XYZ/Embedded/write/write.c
    ${CC} ${CFLAGS} ${LDFLAGS} --static -c  ${WORKDIR}}/home/Linux/NXP/XYZ/Embedded/conf/conf.c
    ${CC} ${CFLAGS} ${LDFLAGS} --static -c  ${WORKDIR}}/home/Linux/NXP/XYZ/Embedded/mainfun/mainfun.c
    ${CC} ${CFLAGS} ${LDFLAGS} --static ${WORKDIR} /home/Linux/NXP/XYZ/Embedded/Read/read.o /home/Linux/NXP/XYZ/Embedded/write/write.o /home/Linux/NXP/XYZ/Embedded/conf/conf.o /home/Linux/NXP/XYZ/Embedded/mainfun/mainfun.o -c XYZ_App
}

do_install() {

    install -m 0755 -d ${D}${bindir}
    install -m 0755 ${S}/XYZ_App ${D}${bindir}
}

--------------------------------------------------------------------------------------------------------------------------------------------------------------

Thanks and Regards,

Bhargav

Labels (2)
0 Kudos
1 Reply

481 Views
gusarambula
NXP TechSupport
NXP TechSupport

Hello Bhargav,

I think it would be better to include the functions from the other .c files as headers on the mainfun.c application. You could convert read.c to read.h and so on, and then add these headers to the main application. That way when compiling your main application, it would call the functions from the headers. You would then just compile mainfun.c on the recipe, which looks correct.

Otherwise you would need to compile into .o files, and these can be linked but mainfunc.c would not have a way to access the functions within these files.

I hope this helps.

Regards,

0 Kudos