cancel
Showing results for 
Search instead for 
Did you mean: 

How to add a .lib file to a project?

Inigo
Associate II

Hello,

I have recently bought an evaluation board. The manufacturer provides a library and a Keil sample project, but I would like to integrate the library in a STM32 Cube project.

I found on the internet how to add a .lib file (www.eclipse.org/.../), but I am still getting the following errors:

<Project Folder>/<lib-name>.lib: error adding symbols: bad value

<Project Folder>/<lib-name>.lib:(pqlib_math_cmsis.o): .symtab local symbol at index 356 (>= sh_info of 178)

make: *** [makefile:75: <filename>.elf] Error 1

6 REPLIES 6
Foued_KH
ST Employee

Hello @Inigo​ 

under Project > Properties > C/C++ Build > Settings > Tool Settings > MCU GCC Linker > Libraries add the .a library name and the path to that file.

Note that you don't enter the "lib" prefix and the extension .a, e.g. when the filename is libmylib.a, enter mylib

Besides, under MCU GCC Compiler > Include paths add the path to the header files to make the compiler happy.

You may keep copies of the .a and .h files within the project folder tree or "out-of-tree" in a separate folder as you prefer.

Note that .a files may exist for different MCU/CPU architectures and ABIs like floating point. Make sure that you get the correct library linked in.

I hope my answer has helped you. When your question is answered please close this topic by marking as Best the reply that answered you, it will help others find that answer faster. Thanks for your contribution. 

Foued

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Pavel A.
Evangelist III

> The manufacturer provides a library and a Keil sample project

Is the library pre-compiled with Keil compiler? If yes you need to rebuild it with gcc (CubeIDE) from source. It will be .a instead of .lib.

I guess so. I don't have the source code and I'm sure that the manufacturer won't share it.

I am using Keil community version and --elf option is not available with my license.

You just have to find a way to do that conversion once and then just continue using your normal version. For example, ask someone who has a more advanced version. Or be more creative...