yocto中的交叉编译库配方 [英] cross-compile library recipe in yocto

查看:177
本文介绍了yocto中的交叉编译库配方的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个几乎没有源代码文件(.c)和头文件的库,输出是共享库(.so).

I have a library with few source code files (.c) and header files and the output is shared library (.so).

当前,我正在使用Makefile生成.so

Currently, i am using Makefile for generating .so

C    = gcc
FLAGS        = # -std=gnu99 -Iinclude
CFLAGS       = -fPIC -g #-pedantic -Wall -Wextra -ggdb3
LDFLAGS      = -shared

DEBUGFLAGS   = -O0 -D _DEBUG
RELEASEFLAGS = -O2 -D NDEBUG -combine -fwhole-program

TARGET  = libesys.so
SOURCES = $(wildcard *.c)
HEADERS = $(wildcard *.h)
OBJECTS = $(SOURCES:.c=.o)


all: $(TARGET)

$(TARGET): $(OBJECTS)
            $(CC) $(FLAGS) $(CFLAGS) $(LDFLAGS) $(DEBUGFLAGS) -o $(TARGET) $(OBJECTS)
clean:
    rm *.o libesys.so

我想在我的meta层中创建一个配方,以执行上述操作并生成.so,以便在进行bitbake core-image-minimal时进行.您能提供一个执行类似操作的示例食谱吗?

I want to create a recipe in my meta layer to perform the above operation and generate .so when I do bitbake core-image-minimal. Can you please provide an example recipe which does similar operation.

推荐答案

首先,查看来自

First, have a look at simple recipe for a single source file from the dev-manual and try to first get a simple recipe building. You are correct in placing this recipe in your own meta layer.

也请参阅

Also have a look at this section that covers recipes with a Makefile.

这是让您入门的东西

DESCRIPTION = "My test recipe"
LICENSE = "CLOSED"
PR = "r1"
S = "${WORKDIR}
FILES_${PN} = "libesys.so"


# Better to use a git repo for large projects
SRC_URI="file://xxxxxx \
         file://yyyyyy \
         "
do_install(){
      oe_runmake install DESTDIR=${D} INCLUDEDIR=${includedir}
      install -d ${D}${libdir}
      install -m 0644 libesys.so ${D}${libdir}
}

BBCLASSEXTEND = "native"

您还需要修改 core-image-minimal 食谱,在食谱中添加一个"depend",以便将其添加到lib中.

You will also need to modify the core-image-minimal recipe to add a depends to your recipe so that it pulls in your lib.

DEPENDS + =在这里输入您的食谱名称"

您可以将其直接添加到配方本身,也可以通过可以驻留在图层中的.bbappends文件添加.

You can add this directly into the recipe itself, or add it via a .bbappends file that can reside in your layer.

这篇关于yocto中的交叉编译库配方的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆