Skip to main content
K2R
Associate II
July 20, 2022
Solved

relative and absolute paths in STM32CubeIDE

  • July 20, 2022
  • 2 replies
  • 5641 views

We're working on a projekt with different µC and some so called "Common-Modules".

These commons are located side by side our projects and shall simply been linked to these.

All this could be done, but on building the project, we noticed, that no modules were built, if the include pathes were relative to the project file. Only if the path is given as an absolute path (for example like "C:\work\thiswork\module1\...") the compilation will be successfull.

As the projects will be built local and on a remote server too, absolute paths are no choice for us.

Are there any solutions to solve this?

Best Regards

This topic has been closed for replies.
Best answer by Pavel A.

>  we noticed, that no modules were built, if the include pathes were relative to the project file.

Of course this does work. A lot of people rely on this. Do you use the standard Eclipse CDT macros, such as ${ProjDirPath} ?

2 replies

Andrew Neil
Super User
July 20, 2022

"if the include pathes were relative to the project file"

Presumably, then, they need to be relative to something else.

"These commons are located side by side our projects"

You could simply avoid the issue completely by having these commons within your projects.

That's the way I'd do it - for this very reason.

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
Pavel A.
Pavel A.Answer
Super User
July 20, 2022

>  we noticed, that no modules were built, if the include pathes were relative to the project file.

Of course this does work. A lot of people rely on this. Do you use the standard Eclipse CDT macros, such as ${ProjDirPath} ?

Andrew Neil
Super User
July 20, 2022

@Pavel A.​ "Do you use the standard Eclipse CDT macros, such as ${ProjDirPath} ?"

Does that work for making a relative path and/or to something not in or below the Project Directory?

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
Pavel A.
Super User
July 20, 2022

@Andrew Neil​ ${ProjDirPath} is substituted to absolute path on the build machine, so it is not relative, strictly speaking.

From there you can step out, for example ${ProjDirPath}/../ 

This is portable to Linux; Eclipse will automatically use correct slashes.

One can also use workspace based paths, if names of other projects included into the workspace are known.