Skip to main content
Associate III
February 26, 2024
Solved

Include a library

  • February 26, 2024
  • 20 replies
  • 15804 views

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

 

This topic has been closed for replies.
Best answer by Andrew Neil

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 ...

20 replies

STTwo-32
ST Technical Moderator
February 26, 2024

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.
Giuseppe1Author
Associate III
March 4, 2024

Thanks!

Andrew Neil
Super User
March 5, 2024

You're welcome.

Yes, one of the things that the Arduino IDE "hides" from you is these details behind adding a library.

Note that there are Arduino cores for STM32s; eg,

https://github.com/stm32duino/Arduino_Core_STM32

https://www.arduino.cc/reference/en/libraries/stm32duino-examples/

So using STM32 doesn't necessarily preclude continuing to use the Arduino IDE...

 


@Giuseppe1 wrote:

I'm still learning to program with the STIde. 


Note that this is general to C (and C++) development - it's not just specific to STM32 or the STM32CubeIDE.

 

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
AScha.3
Super User
February 26, 2024

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 on " Best Answer ".
Giuseppe1Author
Associate III
March 4, 2024

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

Andrew Neil
Super User
March 4, 2024

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.

 

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.