cancel
Showing results for 
Search instead for 
Did you mean: 

Including 3rd party libraries

Hrishikesh
Senior

Hi, I tried including a few .c and .h files from a 3rd party by dragging and dropping them in the `Inc` and `Src` folders in STM32CubeIDE. However, this did not work and when I tried to build the project, I got a lot of errors on the HAL driver library but not the library I was trying to include. What is the best way to add 3rd party `.h` and `.c` files?

4 REPLIES 4
KnarfB
Principal III

There is nothing wrong with dragging additional files into a STM32CubeIDE project. You should make a refresh (F5) and a clean build then to ensure that the IDE has correctly understood all your changes. For larger libraries you can setup separate folders as they are for Drivers... already. Then, you have to add those folders to include and soucre folder lists. Walk through Project Properties C/C++ Build and you get the idea.

Errors are, unfortunately, quite common when merging C source codes. Those are library specific and there is no general switch to switch them of. could be all kinds of type conflicts, name conflicts, missing/wrong configuration #define's etc.. Its an endless story which keeps us alive if we get paid for fixing that.

Thanks! For whatever reason the drag and drop does not work for me. I have to physically copy the files in the Inc and Src folders. After that, like you say, I need to clean the project and rebuild (though I'm having issues with cleaning too).

Behavior of drag and drop files into projects is configured in Window ->Preferences->Workspace->Linked resources.

For more reliable behavior, put files into your filesystem folders, or add linked files manually.

Slower, but gives you more control.

> What is the best way to add 3rd party `.h` and `.c` files?

Whatever you prefer: add all these .c files to the project, or create one or more separate library projects and add their resulting .a files to your main project.

-- pa

Thanks!