cancel
Showing results for 
Search instead for 
Did you mean: 

How to add a existing folder to STM32CubeIDE project?

zqizh.1
Associate II

Hi,

I copy a folder from other project to the STM32CubeIDE project, then do right click and "Refresh", The project explorer will add the folder to the project. I also the new folder path to the project path via "property->c/c++ build->setting->toolchain->mcu gcc compiler->include paths".

The I call the api included in the added folder files in my project file, the compiler will show me error "undefined ***".

Please advise.

Rgds,

Thanks,

QiZhang

4 REPLIES 4
Andrew Neil
Chief III

You need to show the complete message: use copy & paste - don't manually re-type it

Are you sure it's the Compiler saying that?

Normally, "un-defined" would come from the Linker - not the Compiler - and means you haven't included the source or pre-built binary which provides that definition.

The Compiler would only complain about things being un-declared - which usually means you haven't #included a required header file.

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

EDIT

More on declarations vs definitions:

https://www.avrfreaks.net/comment/2545726#comment-2545726

https://www.avrfreaks.net/comment/2545851#comment-2545851

TechGuyMike
Associate III

I've encountered the same issue. I added a .c and an .h file inside a new directory under the directory structure that's already a part of the auto-generated project. The IDE found the directory and added it to the Project Explorer view. I then added the new header file directory to the Include path in build settings. I couldn't figure out how to make the build tools detect my new .c file since the top-level directory above my new directory was already added to the "Source Location" list under Project Properties -> C/C++ General -> Paths and Symbols. So, as a workaround, I manually edited the .project file in the project directory to include my new .c file between the <link> ... </link> tags, and it finally got picked up by the build tools. If there's a better process to add a .c file, I'd like to know it!

As a side-note, I've also tried the drag-and-drop approach to adding a .c file and it didn't work - the .project file doesn't get updated and the compiler toolchain can't find the .c file. And you can't drop a file/folder onto just any folder - only top-level(ish) folders seem to be able to accept a drag-and-drop.

Kmax18
Senior

It has been a while since your question, but hopefully my answer helps somebody else:

In the main menu go to Project -> Properties -> C/C++ General -> Paths and Symbols. Then add your folder.

Kmax18_0-1697516906377.png

 

Rim LANDOLSI
ST Employee

Hello @zqizh.1 ,

 

In order to add an existing folder to STM32CubeIDE project , try to add it using an advanced link. So, Right click on the existing project, then, click on "New Folder" and use the option "Link to alternate location" as shown in the screenshot.
Also, include the path to the project via "property->c/c++ build->setting->toolchain->mcu gcc compiler->include paths".

RimLANDOLSI_0-1697534412602.png

 

 

Thanks,

Rim