STM32 External Source Files

I am writing some C source code for STM32 in CubeIDE and am trying to separate source code that will be reused on multiple designs into an external library (an external as far as SVN is concerned).

In terms of CubeIDE a have a new folder at the top level (same level as the folders Core, Release etc). I call this folder Externals.

My problem comes if I have external files such as Externals/Inc/test.h and Externals/Src/test.c. The system sees the .h files fine if I #include "test.h" in the main files but for some reason I also need to #include "test.c". This makes it work, but I have never seen this done before so I’m thinking something else must be wrong.

>Solution :

Select "Project", then "Properties", "C/C++ General", "Paths and Symbols" and select the "Source Location" tab. Here you can add source code folders (remember to select "All configurations" first).

You can then include/exclude individual files/folders as follows: In the Project Explorer window, right-click on the file/folder, select "Resource Configurations", "Exclude from build" and select/deselect as appropriate.

Leave a Reply