Yocto- gcc找不到共享库

时间:2022-09-18 12:30:30

i have a layer which creates a shared library in usr/lib (libbbexample.so) directory in the Yocto . The library contains several functions .

我有一个层在Yocto的usr / lib(libbbexample.so)目录中创建一个共享库。该库包含多个功能。

So i have created a another new layer in which i wrote a program which will use functions provided from libbbexample.so

所以我创建了另一个新层,我在其中编写了一个程序,该程序将使用libbbexample.so提供的函数

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 tried bitbake the new layer , but i am getting the error "cannot find -libbbexample"

所以我尝试了bitbake新图层,但我收到错误“找不到-libbbexample”

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

新层的.bb文件内容如下

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 priority of old layer which will create the shared library as 6 and the priority of new layer which will make use shared library (.so) as 7 .

我已经设置了旧层的优先级,它将创建共享库为6,新层的优先级将使共享库(.so)为7。

thanks

1 个解决方案

#1


3  

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

要将lib添加到gcc命令,必须从名称中修剪lib。

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:

如果这还不够,你必须在helloworld示例之前编译和安装.so文件。您可以使用:

#1


3  

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

要将lib添加到gcc命令,必须从名称中修剪lib。

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:

如果这还不够,你必须在helloworld示例之前编译和安装.so文件。您可以使用: