Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

DAVE™ Forum Discussions

Not applicable

I would like know how to build a static library with Dave and how to link it with another project.

I have tried to make a new ARM-GCC Library for XMC4500 Project and after add the include and source files I have compiled the code.

Then from the properties of the main project on Settings->ARM-GCC C Linker->Libraries I have added the name of the library in Libraries (-l). After that I have compiled the main code without any error but when the flow of the program arrives to a function of the linked library, the debugger stops working and appears one message saying that the compiler can't find the library.

For other hand, I have tried to build a static library from a Empty Project. From properties menu of the new project on Settings->ARM-GCC C Linker->Miscellaneous I have added the next flags "-shared -fPIC -DPIC" but when I have compiled the project I get the next error.

c:/dave-3.1/arm-gcc/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/bin/ld.exe: library.o: relocation R_ARM_THM_MOVW_ABS_NC against `a local symbol' can not be used when making a shared object; recompile with -fPIC

Anyone had built before a static library? I will be so grateful if someone tells me the steps to do it.

Thanks in advance and best regards,
4 Replies
It should work as follows:

1. Create the library
>File >New >DAVE Project
Select project type: ARM-GCC Library for XMC Project >Empty Project
Define a name
Select a appropriate target device and finish

Create a source file and add your library functions

Build the project
In the artifact folder you should find the library file: lib.a

2. Use the created library
Create an application project (e.g. empty main)
Use in the source files the library functions (declare with extern reference)
Change project properties in C/C++ Build >Settings ->ARM-GCC C Linker -> Libraries:
Add –l option (Libraries):
Add –L option (Library search path): path to Lib.a
Not applicable
Huba, i follow your steps to make and include the library,still errors as MagicPhoton Descripbed. Could you give a staic_lib_example Code and a project to call the static_lib ?
Not applicable
Anybody Can help Me?
Not applicable

Attached is a simple example for your reference.

You also can place the library file (*.a) under your application project folder. Do remember to change the library search path.

Best regards,