Building a static library
Posted: Fri Apr 18, 2014 2:54 am
I'm trying to create a static library (*.a file) containing an entire project for the STM32F407-Discovery board. The goal is it to have a static library which can be compiled/linked with only a main.c to create a working project. However, I horribly fail at it.
What I did is taking the /demos/ARMCM4-STM32F407-DISCOVERY project and modify the Makefile. I removed main.c from the CSRC variable. Then I added the following to the very bottom of the Makefile:
This way I could create the chibios.a library by executing
To create the actual project, I added only the main.c to the CSRC variable and I also added the chibios.a library to the ULIBS variable. Then I ran the Makefile normally just by executing Everything compiled and linked successfully. However, the created binary does not work at all (nothing gets executed at all).
I sadly don't know where the problem is but I am quite sure that it has something to do with how I create the static library. I don't really see through all the Makefile magic inside of /os/ports/GCC/ARMCMx/rules.mk to find out what I'm doing wrong.
I attached the .map file of the working project and the one with the library. The .map file of the library project does show some difference to the other at the start address:
whilst the working one is
However, I don't really know how to fix this.
Can anybody help?
~ Tectu
What I did is taking the /demos/ARMCM4-STM32F407-DISCOVERY project and modify the Makefile. I removed main.c from the CSRC variable. Then I added the following to the very bottom of the Makefile:
Code: Select all
chibios.a: $(OBJS)
arm-none-eabi-ar r $@ $^
This way I could create the chibios.a library by executing
Code: Select all
make chibios.aTo create the actual project, I added only the main.c to the CSRC variable and I also added the chibios.a library to the ULIBS variable. Then I ran the Makefile normally just by executing
Code: Select all
makeI sadly don't know where the problem is but I am quite sure that it has something to do with how I create the static library. I don't really see through all the Makefile magic inside of /os/ports/GCC/ARMCMx/rules.mk to find out what I'm doing wrong.
I attached the .map file of the working project and the one with the library. The .map file of the library project does show some difference to the other at the start address:
Code: Select all
startup
*(vectors)
constructors 0x08000000 0x0
0x08000000 PROVIDE (__init_array_start, .)
whilst the working one is
Code: Select all
startup 0x08000000 0x188
*(vectors)
vectors 0x08000000 0x188 build/obj/vectors.o
0x08000000 _vectors
Can anybody help?
~ Tectu