Search code examples
cgccldcortex-m

How to add a libgcc.a library to my keil project


I need to make a library for a customer who is using GCC. I have a working Keil project compiled with the GCC. The next step is to make a library. I removed from the project main file and Keil generated libname.a library file. Now I want to create a new project with the same main and libname.a library. I'm failing to do so. I added this library to Options/Linker tab, added library path and getting "c:/gnu arm embedded toolchain/10p3_2021_10/bin/../lib/gcc/arm-none-eabi/10.3.1/../../../../arm-none-eabi/bin/ld.exe: cannot find -llibname.a Here is all the options/flags:

-mcpu=cortex-m4 -mthumb -o ./DebugConfig/name_main.elf -L ./DebugConfig *.o -llibname.a -mcpu=cortex-m4 --specs=nosys.specs -Wl,--gc-sections -static -Wl,--start-group -Wl,--end-group --specs=nano.specs -mthumb -Wl,--start-group -lc -lm -Wl,--end-group

Thank you in advance.


Solution

  • All that was needed is to put a colon in front of the name :libname.a ...

    I hate fighting with tools. Here is the solution: I need to add into the misc section separately -L path\lib\one -l libname Or -l:name.a

    I did not find where it is written that my options are:

    1. -l name and in this case libname.a file will be searched for;
    2. -l:name.a and in this case name.a file is the target library.

    Why does it have to be so convoluted and complicated... This is just a rhetorical question, obviously. I hope this will help someone else in the future.