With the Makefile and hello.bb listed below I am able to compile and run my C project on target device. 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:
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
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
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.
You need to add libmicrohttpd
and json-c
to RDEPENDS
(Runtime dependencies):
RDEPENDS_${PN} += "libmicrohttpd json-c"