Static linking on CDP

Home Forums MultiConnect OCG Static linking on CDP

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #2571
    David Hearn
    Participant

    Hi.

    I’m still at the tail end of the learning curve of CDP and openembedded. I’m working on an application based in part on sms-utils, and have managed to get sms-utils functionality copied into a new package called myapp. This new application uses explicit compile and link statements, rather than autotools.

    Builds fine and runs in CDP using shared objects (and after installing libyaml and libesmtp on CDP), but of I try to link statically, linking fails with about 25 complaints about missing references to various functions in both libesmtp and libyaml like the following:

    [path]/sms_send_email.c:310: undefined reference to `auth_client_init’

    -or-

    [path]/sms_config.c:45: undefined reference to `yaml_parser_delete’

    I’ve moved [path]/usr/lib/libyaml.a and libesmtp.a out of the way, and the build fails stating the files don’t exist, so I definitely know they’re being accessed and examined. I’ve also tried rebaking both librairies, but woith the same results.

    Any ideas why static linlking fails like this? I’ve tried just about everything I can think of. This is more of a learning question, as I’ll likely be using shared objects in production. I’m just baffled as to why I can’t statically link. In the below recipe, the first 16 objects compile without error, but when we try to link together my_sms_main, the errors result.

    Thanks

    Here’s the recipe:

    DESCRIPTION = “myapp”

    SECTION = “examples”

    LICENSE = “GPL”

    DEPENDS = “libesmtp libyaml”

    SRC_URI = “file://atcmd.h

    file://cmd_options.h

    file://config.h

    file://global.h

    file://list.h

    file://log.h

    file://pdu_decode.h

    file://pdu_encode.h

    file://pdu.h

    file://phonebook.h

    file://sms_config.h

    file://sms_delete.h

    file://sms_list.h

    file://sms_send_email.h

    file://sms_send.h

    file://sms_utils.h

    file://utils.h

    file://xprintf.h

    file://sms_main.c

    file://sms_utils.c

    file://sms_send.c

    file://sms_send_email.c

    file://sms_list.c

    file://sms_config.c

    file://phonebook.c

    file://sms_delete.c

    file://xprintf.c

    file://utils.c

    file://atcmd.c

    file://pdu.c

    file://pdu_decode.c

    file://pdu_encode.c

    file://pdu_decoder.c

    file://pdu_encoder.c”

    S = “${WORKDIR}”

    do_compile() {

    ${CC} ${CFLAGS} -c sms_utils.c

    ${CC} ${CFLAGS} -c sms_send_email.c

    ${CC} ${CFLAGS} -c sms_list.c

    ${CC} ${CFLAGS} -c sms_config.c

    ${CC} ${CFLAGS} -c phonebook.c

    ${CC} ${CFLAGS} -c sms_delete.c

    ${CC} ${CFLAGS} -c xprintf.c

    ${CC} ${CFLAGS} -c utils.c

    ${CC} ${CFLAGS} -c atcmd.c

    ${CC} ${CFLAGS} -c pdu.c

    ${CC} ${CFLAGS} -c pdu_decode.c

    ${CC} ${CFLAGS} -c pdu_decoder.c

    ${CC} ${CFLAGS} -c pdu_encode.c

    ${CC} ${CFLAGS} -c pdu_encoder.c

    ${CC} ${CFLAGS} -c sms_send.c

    ${CC} ${CFLAGS} -c sms_main.c

    ${CC} ${LDFLAGS} –disable-shared -lyaml -lesmtp -o my_sms_main

    sms_main.o sms_utils.o sms_send.o sms_send_email.o sms_list.o

    sms_config.o phonebook.o sms_delete.o xprintf.o utils.o atcmd.o pdu.o

    pdu_decode.o pdu_encode.o -static

    ${CC} ${LDFLAGS} –disable-shared -lyaml -lesmtp -o my_pdu_decoder

    pdu_decoder.o pdu_decode.o pdu_encode.o utils.o atcmd.o pdu.o

    xprintf.o sms_utils.o -static

    ${CC} ${LDFLAGS} –disable-shared -lyaml -lesmtp -o my_pdu_encoder

    pdu_encoder.o pdu_decode.o pdu_encode.o utils.o atcmd.o pdu.o

    xprintf.o sms_utils.o -static

    }

    do_install() {

    install -d ${D}${bindir}

    install -m 0755 my_sms_main ${D}${bindir}

    install -m 0755 my_pdu_decoder ${D}${bindir}

    install -m 0755 my_pdu_encoder ${D}${bindir}

    }

    #3177
    Jesse Gilles
    Blocked

    The linker options to gcc need to be at the end. Try moving “-lyaml -lesmtp” to the end of the list.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.