cancel
Showing results for 
Search instead for 
Did you mean: 

Include a library

Giuseppe1
Associate III

Hi. I have seen several tutorials and read in the forum how to include a library. But it does not work. Can someone help me please.

Giuseppe1_0-1708950592928.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
20 REPLIES 20
STTwo-32
ST Employee

Hello @Giuseppe1 

Can you take a look at the following article and this post. It may be helpful.

Best Regards.

STTwo-32

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.

AScha.3
Chief II

Hi,

maybe error msg is right ? There is no such file... 

So you have to "import" it : right click on the directory, you want it to be ->

AScha3_0-1708952974440.png

next -> browse the source , select what want - ready.

This for every source .c or .h (or group of ..) , then the IDE got it.

 

If you feel a post has answered your question, please click "Accept as Solution".

I created a new folder with the library(.h). Then i imported it : Project->Properties->MCU GCC linker->libraries. but it doesn't work.

A header file is not a library - it just defines the interface to the library.

So, in addition to that header, you will also need the library code itself - either as a pre-built binary, or as source code.

  • You use Project->Properties->MCU GCC linker->libraries to specify a pre-built binary library - see the links posted by @STTwo-32 
  • If it's a source code library, you add all the source to your project, so  that it gets built as part of your project.

 

This is the file. It's a source code?

It is "source code" in that it is used as input to the compiler. It's not a binary file.

But, again, it's just a header file - as it says, it only contains prototypes - not the functions themselves:

 

 

 * @brief   This file contains all the functions prototypes for the
 *          lsm6dso_reg.c driver.

 

 

You also need something which contains the actual implementations of those functions - either as source code, or a pre-built binary.

I suggest you look at the X-CUBE-MEMS1 and/or C-Driver-MEMS software packs:

 

AndrewNeil_0-1709565019709.png

 

https://www.st.com/en/mems-and-sensors/lsm6dso.html#tools-software 

 

EDIT

For a better understanding of the difference between declarations and definitions, and how data & functions can be defined in one file, but used in another, see:

https://c-faq.com/decl/decldef.html 

I installed the driver file, now how do you import it?

https://community.st.com/t5/stm32cubeide-mcus/include-a-library/m-p/646526/highlight/true#M24844

You'll also have to study the Pack's documentation on how to use it ...

Thanks!