HOWTO: Add a static library file into S32DS GCC project

Showing results for 
Show  only  | Search instead for 
Did you mean: 

HOWTO: Add a static library file into S32DS GCC project

No ratings

HOWTO: Add a static library file into S32DS GCC project

This document describes two ways how to add a static library file (*.a) into your S32 Design Studio GCC project. These methods differs from each other in sense how a library update is reflected into project build process.

Adding a static library WITHOUT dependency to executable (elf) file

This approach assumes a library does not change. An update of the library does not trigger project rebuild process. If the library changes the project needs to be manually cleaned (assuming no other source file has changed) and next build links the updated library.

The path to the library and the library name shall be entered into Project Properties -> C/C++ Build -> Settings -> Standard S32DS C Linker -> Libraries


Please note that GCC adds prefix "lib" and the extension ".a"  to the library name entered into the above dialog by default.

GCC linker will search for the library file named: "libtestlib.a" in the folder "c:\my_libs" In the example above.

In case a library cannot be found the linker error occurs e.g. one depicted below. The linker library file name option "-ltestlib.a" is expanded into file name "libtestlib.a.a" which does not exist.

10:28:53 **** Incremental Build of configuration Debug for project S32K144_Project_with_library ****
make -j8 all 
Building target: S32K144_Project_with_library.elf
Executing target #5 S32K144_Project_with_library.elf
Invoking: Standard S32DS C Linker
arm-none-eabi-gcc -o "S32K144_Project_with_library.elf" "@S32K144_Project_with_library.args" 
c:/nxp/s32ds_arm_v2.0/cross_tools/gcc-arm-none-eabi-4_9/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/bin/ld.exe: cannot find -ltestlib.a
collect2.exe: error: ld returned 1 exit status
make: *** [makefile:49: S32K144_Project_with_library.elf] Error 1
10:28:54 Build Finished (took 1s.332ms)‍‍‍‍‍‍‍‍‍‍

For a custom library name add colon character ":" at the beginning of the library name to disable the default prefix/extension expansion.

GCC linker now searches for file name "testlib.lib" in the example below:



Adding a static library WITH dependency to executable (elf) file

If a static library has changed - "touched"  it is sometimes desired to trigger project rebuild. In this scenario the library shall be added into a different project dialog:

Project Properties -> C/C++ Build -> Settings -> Standard S32DS C Linker -> Miscellaneous -> Other objects


The items from "Other objects" list is propagated into USER_OBJS makefile variable which is prerequisite for auto-generated makefile rule that build the target (elf):


Enjoy linking static libraries in S32DS!


how to add a .o file into s32ds gcc project?

Hi Liu,

You can add an object file into linker in the same way as library file - Standard S32DS Linker -> Other Objects -> enter your .o file

Hope it helps.


Version history
Last update:
‎09-10-2020 02:11 AM
Updated by: