Yocto- gcc 找不到共享库

Yocto- gcc cannot find shared library

我有一个层在 Yocto 的 usr/lib (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;
}

所以我尝试对新层进行 bitbake,但出现错误 "cannot find -libbbexample"

新图层.bb文件内容如下

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

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

我已经将创建共享库的旧层的优先级设置为 6 以及使用共享库 (.so) 的新层的优先级为 7 .

感谢

要将库添加到您的 gcc 命令,您必须 trim 名称中的 lib

改变

-libbbexample

-lbbexample

The man作为参考。

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