Force linking a library

Sysprogs forums Forums VisualGDB Force linking a library

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #813
    lxh
    Participant

    I’m developing an application for the Raspberry Pi, using the Pi camera. It uses the mmal libraries. I’ve taken a simple application, that compiles on the Pi itself (using GNU C++), and runs fine. If I compile it on Windows using the cross compiler toolchain, it does not run but gives a vague error:

    mmal: mmal_component_create_core: could not find component 'vc.ril.camera'

    When I compare the binaries on the Pi using ldd, I see that one library is not linked in the executable: libmmal_vc_client.so
    My suspicion is that the cross compiler toolchain omits linking to a library that understands what “vc.ril.camera” is.

    How can I force the toolchain to link this library? I already tried (through VisualGDB Project Properties / Makefile settings):

    • add the library name in the Library names box
    • switch of linker optimisation (-O0)
    • switch of garbage collection of sections (LDFLAG –no-gc-sections )
    • add the library name as a LDFLAGS entry

    My LDFLAGS setting is now
    -Wl,–no-gc-sections -Wl,–print-gc-sections -Wl,-O0 -Wl,–trace -Wl,-Bdynamic -lmmal_vc_client
    note: option “Use -Wl,–start-group and -Wl,–end-group” is checked

    And if anyone can point me into the direction of some proper documentation, I would be much obliged!

    #3147
    support
    Keymaster

    Hi,

    Forcing to link against a library with no actual functions imported would not solve the problem if some component is missing. Please try examining the symbol table of the module that links against the library correctly (readelf -s ), find out which functions are imported from libmmal_vc_client.so and then see why they are not imported on the version built with the cross-compiler (enable creation of a map file to see details about functions).

    #3145
    lxh
    Participant

    There are 2 main differences in Symbol table .dynsym.

    The working version includes:

    • 48: 000090b0 0 FUNC GLOBAL DEFAULT UND __stack_chk_fail@GLIBC_2.4
    • 9: 00015168 4 OBJECT GLOBAL DEFAULT 24 __stack_chk_guard@GLIBC_2.4

    Furthermore, a couple of minor differences in the 7th parameter (NDX?) of the output (e.g. 26 vs 24)

    in the table .symtab, the same number of entries are present, the order is slightly different (lots of numbers that are not so meaningful to me). The difference is that the correct executable has these entries (not surprising given the above)

    • __stack_chk_fail@@GLIBC_2
    • __stack_chk_guard@@GLIBC_

    I’m stumped

    how do I create a map file? Is that with LDFLAGS including -Xlinker -Map=output.map?

    #3146
    support
    Keymaster

    Yes, simply add -Wl,-Map=output.map to LDFLAGS. Actually, can you send both binaries (the ones with and without a reference to libmmal_vc_client) to our support email? We should be able to see the difference from a quick look at the section dump and some disassembly.

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