简体   繁体   English

Bitbake 构建了 C 项目,但不包括镜像 rootfs 的依赖库

[英]Bitbake builds C project but does not include dependent libraries to image rootfs

With the Makefile and hello.bb listed below I am able to compile and run my C project on target device.使用下面列出的 Makefile 和 hello.bb,我可以在目标设备上编译和运行我的 C 项目。 The issue I am facing is that libraries sqlite3 libmicrohttpd json-c are not included to rootfs of the image and I'm getting errors like that:我面临的问题是库sqlite3 libmicrohttpd json-c未包含在图像的 rootfs 中,我收到这样的错误:

admin@orange-pi-r1:~# /var/hello.bin
Error loading shared library libmicrohttpd.so.12: No such file or directory (needed by /var/hello.bin)
Error loading shared library libjson-c.so.5: No such file or directory (needed by /var/hello.bin)
Error relocating /var/hello.bin: json_object_new_string: symbol not found
Error relocating /var/hello.bin: MHD_destroy_response: symbol not found
Error relocating /var/hello.bin: json_object_object_add: symbol not found
Error relocating /var/hello.bin: MHD_create_response_from_buffer: symbol not found
Error relocating /var/hello.bin: MHD_queue_response: symbol not found
Error relocating /var/hello.bin: MHD_start_daemon: symbol not found
Error relocating /var/hello.bin: json_object_new_array: symbol not found
Error relocating /var/hello.bin: MHD_add_response_header: symbol not found
Error relocating /var/hello.bin: json_object_put: symbol not found
Error relocating /var/hello.bin: json_object_to_json_string: symbol not found
Error relocating /var/hello.bin: MHD_stop_daemon: symbol not found
Error relocating /var/hello.bin: json_object_new_object: symbol not found
Error relocating /var/hello.bin: json_object_array_add: symbol not found
Error relocating /var/hello.bin: json_object_new_int: symbol not found

Why is that and how to fix it?为什么会这样以及如何解决?

hello.bb recipe你好.bb食谱

SUMMARY = "hello"
LICENSE = "CLOSED"

SRCBRANCH = "hello"
SRCREV = "03b9c21ef46973d2a285db785a04620ebaf25db2"

SRC_URI = "git://git@bitbucket.org/hello/hello.git;branch=${SRCBRANCH};protocol=ssh"

S = "${WORKDIR}/git"

DEPENDS = "sqlite3 libmicrohttpd json-c"

INSANE_SKIP:${PN} += "ldflags"

do_compile() {
    cd ${S}/src && oe_runmake
}

do_install() {
    install -d ${D}/var/
    install -m 0644 ${S}/src/hello.bin ${D}/var/hello.bin
}

FILES:${PN} = "/var/hello.bin"

Makefile Makefile

CC ?= gcc

CFLAGS += -O2
CFLAGS += -I./include
CFLAGS += -I${STAGING_INCDIR}/usr/lib

LDLIBS += -lmicrohttpd -lsqlite3 -ljson-c
LDFLAGS += -L${STAGING_LIBDIR}/usr/lib

cc-headers = \
    hello.h \
    hello_db.h \
    hello_http.h \
    hello_list.h

cc-targets = \
    hello.o \
    hello_db.o \
    hello_http.o

%.o: %.c $(cc-headers)
    $(CC) -c -o $@ $< $(CFLAGS)

all: $(cc-targets)
    $(CC) -o helo.bin $(CFLAGS) $(LDLIBS) $(cc-targets)

clean:
    rm *.o

DEPENDS specifies build time dependencies. DEPENDS指定构建时间依赖性。

You need to add libmicrohttpd and json-c to RDEPENDS (Runtime dependencies):您需要将libmicrohttpdjson-c添加到RDEPENDS (运行时依赖项):

RDEPENDS_${PN} += "libmicrohttpd json-c"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM