2021-02-22 02:24 AM
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
2021-02-22 04:24 AM
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:
2022-09-07 11:26 AM
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.
2023-10-16 09:29 PM - edited 2023-10-16 09:30 PM
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.
2023-10-17 02:21 AM - edited 2023-10-17 02:22 AM
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".
Thanks,
Rim