sampat nayak
sampat nayak

Reputation: 123

Yocto- gcc cannot find shared library

I have a layer which creates a shared library (libbbexample.so) in usr/lib directory in a distribution build by Yocto. The library contains several functions.

So I have created a new layer in which I have written a program which will use functions provided by libbbexample.so.

File helloworld.c:

#incude<stdio.h>
#include<bbexample.h>

int main()
{
    int data;
    
    data = get_data(); // this function is present in libbbexample.so 
    
    printf("data is %d",data);
    
    return 0;
}

So I have tried bitbake the new layer, but I am getting the error "cannot find -libbbexample".

The contents of .bb files of new layer are as follows

do_compile() {
    ${CC} helloworld.c -o helloworld -libbbexample ${LDFLAGS} 
}

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

I have set the following priority for layers:

Thanks

Upvotes: 2

Views: 4937

Answers (1)

LPs
LPs

Reputation: 16243

To add lib to your gcc command you have to trim the lib from the name.

Change

-libbbexample

with

-lbbexample

The man as reference.

If this is not enough you have to grand that .so file is compiled and installed before the helloworld example. You can use:

Upvotes: 5

Related Questions