By default, the GNU Linker expects a very special naming scheme for the libraries: the library name has to be surrounded by “lib” and the “.a” extension:
But what if the library I want to use does not conform to that naming standard?
As outlined in Creating and using Libraries with ARM gcc and Eclipse the library name has to be something like
with the ‘lib’ prefix and the ‘.a’ as extension.
What is a common confusion point: for the linker I have to specify the library using the -l option without (!!!) the prefix and extension:
Using Eclipse (e.g. NXP MCUXpresso IDE), I have a dialog where I can put in the library name (-l option) and where the library is located (-L option):
So how to use a library with a non-standard naming? Obviously I can rename the library (this is actually what I did in the past). But there is yet another way: use the ‘:’ (colon) in the linker -l option. If using the ‘:’ I can specify the real library name with
For example if my library is named
I can use
The same thing works in the Eclipse dialog:
That’s it! 🙂
Happy GNU Linking 🙂
Wow, that was easy but hidden. Thanks so much 🙂
Pingback: Tutorial: Porting BLE+NRF Kinetis Design Studio Project to MCUXpresso IDE | MCU on Eclipse
Pingback: Managing Project and Library Dependencies with Eclipse CDT | MCU on Eclipse