Thanks for responding. However, the question is not "why out of the box platformio tools are not sufficient to build an example project, it is "how to use precompiled library in archive format and let liker take it “as is” and link it with the other *.o modules compiled in the platformio enfironment. I spent couple of days in unsuccessful attempts to make it work, including your recommendations.
First I naively included the path to *.a file in lib_path.
Then I added
-L "C:\PlatformIO\libopencm3\lib\libopencm3_stm32f1"
-llibopencm3_stm32f1.a
in build_flags. The path to the library appeared in the link command but “.a” was stripped off.
Then I found your recommendation, which is to place the library in /lib/libopencm3 folder, together with empty header file and a library.json file:
{ "build": {
"flags": [
"-L.",
"-llibopencm3_stm32f1.a"
]
}
}
As the result, an empty libopencm3_stm32f1.a library is generated in C:\PlatformIO\STM32_libopencm3.pio\build\bluepill_f103c8\libcda, and the latter appears in the linkage command line. Then, the linker cannot find symbols in this library (because it is empty!):
**arm-none-eabi-gcc-ar rc .pio\build\bluepill_f103c8\libcda\libopencm3_stm32f1.a**
arm-none-eabi-gcc-ar rc .pio\build\bluepill_f103c8\libe89\libinclude.a
Building in release mode
arm-none-eabi-gcc -o .pio\build\bluepill_f103c8\firmware.elf -Os -Wl,--gc-sections,--relax -mthumb -mcpu=cortex-m3 .pio\build\bluepill_f103c8\src\StrPrintf.o .pio\build\bluepill_f103c8\src\led.o .pio\build\bluepill_f103c8\src\systick.o .pio\build\bluepill_f103c8\src\uart.o .pio\build\bluepill_f103c8\src\usb-serial.o .pio\build\bluepill_f103c8\src\usb.o -Llib\libopencm3_stm32f1 -LC:\Users\Win7\.platformio\platforms\ststm32\ldscripts -L.pio\build\bluepill_f103c8 -Wl,--start-group -lopencm3_stm32f1 **.pio\build\bluepill_f103c8\libcda\libopencm3_stm32f1.a** .pio\build\bluepill_f103c8\libe89\libinclude.a -lc -lgcc -lm -lstdc++ -Wl,--end-group
c:/users/win7/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/bin/ld.exe: c:/users/win7/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/lib/thumb/v7-m/nofp\libc.a(lib_a-exit.o): in function `exit':
**exit.c:(.text.exit+0x16): undefined reference to `_exit'**
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\bluepill_f103c8\firmware.elf] Error 1
So the real question: how to specify an insertion into the linker command file to use an *.a file from any specific location? In other words, I want the “C:\PlatformIO\STM32_libopencm3\lib\libopencm3_stm32f1.libopencm3_stm32f1.a” , not “.pio\build\bluepill_f103c8\libcda\libopencm3_stm32f1.a” in the linker command line.
Do you know of any option to specify additional arguments “as is” into the linker command line?