cancel
Showing results for 
Search instead for 
Did you mean: 

Adding a source file / folder to a project

PG.1
Associate III

Hello!

One problem I had today:

I made a new project for one specific question.

In the process of doing this, I created a file. Let's call it test.c / test.h using STM32CubeIDE, V1.7, Linux.

To start from the beginning, I added a source folder, and created a h file and c file in this folder (test.c / .h)

I added include "test.h" in main. The compiler doesn't' find test.h.

 

Is there anything else to do? The folder I created has a small C in its icon, which indicates it's recognized

as a source folder, so I don't get it...

Thanks for any hint!

PG

 

2 REPLIES 2
TDK
Guru

To have it find test.h when you #include it, add the folder to the include directories in project properties:

TDK_0-1736434492656.png

 

To add a folder with source code that it needs to compile, add that folder in the "Source Location" tab shown in the screenshot.

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

Can be many reasons. But anybody would need more info to help you.

A) you have an STM32CubeIde project AAA created with STM32CubeIde  - correct?

B) than you have a tree structure, a main.c file in some src directory - correct? 

C) you have added to src directory some files, test. c and test .h - ok?

D) IDE indexes files - use command refresh. 

E) now you must say to compiler where .h file are - go to properties, compiler, include files dir and add src directory. - solved?

For your reference:

I strongly suggest to include step by step description on how you got to critical point - if eveybody is able to recreate from SCRATCH (this is vital) the problem somebody could help you:

1) describe the steps you did, one by one;

2) try yourself to replicate the problem executing your steps one by one