Don't Use Static Libraries in Embedded Project?
I found a problem with static libraries that prevents their use at least with Atollic true studio and wondering if there are other tools on the market that will be able to handle it or should I forget the libraries once and forever
:(
.We have a system consisting of multiple STM32H7 MCUs communicating over some data bus. The natural and proper way to organize such project workspace is to have several static libraries (one for cross-platform algorithms, one for project-specific such as data bus protocol functions, one for sharing data formats with back office software, etc). Executable project for MCU will have most of its code implementation residing in such static libraries and only invoking public interfaces from them.
However, linker removes symbols from the library if its symbols are not explicitly referenced by the executable project and only referenced by the other static libraries.
For example, lets say we have two static libraries Lib1 and Lib2. Lib2 implements function 'Main' that uses function 'Calc' which is implemented in Lib1. Executable project links Lib1 and then links Lib2. Because executable project does not use function 'Calc' explicitly, it gets removed after linking Lib1. After linking Lib2 linker reports that symbol 'Calc' is not found.
In the real life libraries contain thousands of symbols and simple work arounds such as dummy explicit references from the executable don't work (because of private symbol declaratoins in libraries as one of the reasons). Disabling optimization such as dead code removal also does not help.
The only work around that I presently see is not to use static libraries at all in any projects, which will be a disappointing decision.
