0

I have a library mylib.lib created using Keil MDK. I have a GCC project (STM Cube) where I need to use this library. It seems to me it wants libmylib.a file. Could you please let me know how to do so. Thanks.

Submin
  • 19
  • 4

1 Answers1

0
..ARMCC\bin\fromelf.exe --elf mylib.lib --output mylib.elf

Add mylib.elf to the library list used in the gcc based project.

MaartenDev
  • 5,631
  • 5
  • 21
  • 33
  • Thank you gentlemen, I'll try to follow your advice ASAP and let you know. – Submin Dec 20 '21 at 13:57
  • My attempt failed. I did follow #1. No problem there. The problem is that then I need to include my library to a project made with STM Cube. GCC library .a builds fine. Cube doesn't see .elf. The same if I change extension to .a... Description: cannot find -lmy_lib – Submin Dec 23 '21 at 23:33
  • Add the elf file not as a library but as an additional object file. – ColdWeather Dec 25 '21 at 07:02
  • Could you please tell me how to do so using STM Cube? Do I need just manually change .ld file or GUI allows doing that? Thanks. – Submin Dec 27 '21 at 13:51
  • https://stackoverflow.com/questions/32681360/gcc-can-compile-with-object-file-compiled-from-keil-arm-compiler – Submin Dec 27 '21 at 13:56
  • Open Project properties, there: C/C++ Build -> Settings -> MCU GCC Linker -> Miscellaneous -> Additional Object Files -> Add (the file(s), converted by FROMELF.EXE from .LIB or .O in KEIL-Format). – ColdWeather Jan 02 '22 at 21:08
  • As I described above, I need to add mylib to the CUBE project. I don't see any list of obj files within given ld file. Files with the extension .a(or maybe .lib but only one of them) are just added to the such project. Cube doesn't take .elf. Changing the extension did not help. – Submin Jan 03 '22 at 23:02
  • 1. LD file is a linker script file. TyPo? 2. I have no idea, what does not work in your system. I can just repeat: 2.1. convert *.LIB files created under KEIL to *.elf by FROMELF as I wrote before. 2.2. Add those converted files to the list of the additional object files in project settings as I also wrote before. 2.3. Pay special attention, to what configuration - debug or release - you add the files: may be you add them to release but compile debug and have error messages. – ColdWeather Jan 06 '22 at 18:58