0

I am trying to statically cross-compile an Application for ARM using the Linaro-Toolchain 7.1.1 . The final elf file is dependent on two shared-objects. I need to statically compile the application because there are dependencies that are not available on my target-system (eg. libstdc++). The -L and -I flags are in the makefile and everything works normally without the -static Flag. However when i use the -static flag, my linaro-linker tells me that it cannot find the dependencies, even though i know they are there as liba.so and libb.so. Any help or point to literature is appreciated, i feel like i did not fully understand what -static does, eventhough i did my research online.

Thanks

Matze
  • 11
  • 4
  • 1
    Provide the literal diagnostics text, as well as the compile and linker commands executed. I won't be able to help you but others may. – Cheers and hth. - Alf Nov 17 '17 at 19:42
  • You need the `.a` versions of the library to statically link, not the `.so` versions. If you have the `.so` versions why not just copy them to the target device in addition to your binary? – Gillespie Nov 17 '17 at 19:43
  • It's not super clear what you're asking. It seems like you're wondering why you're unable to statically link your libraries. I would recommend adding some formatting to your question and give us some details about what you've tried. – Gogeta70 Nov 17 '17 at 19:44
  • Read also: https://stackoverflow.com/a/8692187/2516916 – Gillespie Nov 17 '17 at 19:44

1 Answers1

0

Thanks to your comments i was able to solve my problem and understand why i had it. As user RPGillespie mentioned, the -static flag needs archived (libx.a) versions of the objects, so i had to compile the .o files to .a files using the ar-tool from the linaro toolchain.

Furthermore, as user RPGillespie refered me to, i had to specify the archives x using -l:libx.a instead of -lx in the g++ command.

Also it took me some time to notice that if the x.a files are not present, the linker will link dynamically. In my makefile the executable was compiled before the x.a file was available (because i just modified the makefile used to build the x.so).

Matze
  • 11
  • 4