Sysprogs forums › Forums › VisualGDB › Force linking a library
- This topic has 3 replies, 2 voices, and was last updated 10 years, 7 months ago by support.
-
AuthorPosts
-
April 24, 2014 at 14:56 #813lxhParticipant
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 checkedAnd if anyone can point me into the direction of some proper documentation, I would be much obliged!
April 28, 2014 at 03:07 #3147supportKeymasterHi,
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). April 30, 2014 at 16:39 #3145lxhParticipantThere 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?
May 2, 2014 at 18:04 #3146supportKeymasterYes, 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.
-
AuthorPosts
- You must be logged in to reply to this topic.