Skip to main content
DavePfz
Associate III
August 31, 2026
Solved

How to move a project to a new directory?

  • August 31, 2026
  • 9 replies
  • 204 views

I would like to move the project from:

C:\ST\STM32Cube_FW_WB_V1.24.0\Projects\P-NUCLEO-WB55.Nucleo\Applications\BLE\BLE_HeartRateFreeRTOS

to:

C:\Projects\Myproject

so that I can make modifications at will and not worry about corrupting the original code. At the same time, I want all the libraries, etc. to fall under the same directory as the new code will eventually be submitted to version control.

How can I do this?

Note: All my other projects under the C:\Projects directory were started with CubeMX and all seem to do as I want.

Best answer by DavePfz

After following the various methods proposed by the responders, I found that this procedure works:

First make a new directory in parallel to the existing example project. For example, I took:

C:\ST\STM32Cube_FW_WB_V1.24.0\Projects\P-NUCLEO-WB55.Nucleo\Applications\BLE\BLE_HeartRateFreeRTOS

and made the parallel using my initials to make it different:

C:\ST\STM32Cube_FW_WB_V1.24.0\Projects\P-NUCLEO-WB55.Nucleo\Applications\BLE\DJP_HeartRateFreeRTOS

Copy the files under the old into the new - all of them.

In the new area, find the ioc file and rename it to match the new directory.

Inside the ioc file edit (in text mode) change all occurrences of the old into the new. In my case, there were three occurrences.

At this point you should be able to pull up STM32CubeIDE and compile and run. This is just a check that nothing is broken.

Now pull up STM32CubeMX with the new ioc file. Under the Project Manager → Code Generator tab, select either of the bullets that copy the library files. It is important to remove the “library files as references”. (While there, check that the blocks in the “Generated files” section are what you want. I like the peripheral files as separate ‘c’ and ‘h’ files, but that’s just a personal preference.)

Now, click on [Generate Code], recompile and verify it still works.

At this point, just copy the entire ‘new’ directory structure to wherever you want. Point the tools (MX or IDE) to these new area and it should “Just work.”

Two added notes:

I found that trying to generate the application using MX either required that I fill everything out or one file (hrs_app.c) was corrupt and I had to manually copy it from the original location. For this example, I found using MX was just frustrating!

Also, the same file seems to be affected whenever code is regenerated. This is something that’s beyond me. I haven’t tried this since I moved the project to the new directory, so this may be a fluke.

 

9 replies

TDK
August 31, 2026
"If you feel a post has answered your question, please click ""Accept as Solution""."
MM..1
Super User
August 31, 2026

I mean is more complicated as ​@TDK refer. But if you have space simply copy STM32Cube_FW_WB_V1.24.0 into your project folder completely and then remove unused parts. Example applications isnt so simple to clone. Second way is in MX choice example by name and export into new project if this same exist here.

MGogr.1
Senior
September 1, 2026

Simply copy your required projects into desired Folder C:\Projects\Myproject and then open from that folder and make changes as required. And then you can use that project in version control.

This will help you in preserving original project as well as making changes in version control projects.

 

DavePfz
DavePfzAuthor
Associate III
September 2, 2026

That was my first approach and it failed miserably! The key point is that in the projects as distributed by ST the libraries use relative referencing. The end result is a message from the compiler like:Can’t find ../../../../../xxx.h. Trying to resolve this on a file-by-file basis only drives me bonkers!

I can understand why this is done in that it saves a lot of disk space for all of the examples included. There may be a way to save a project while converting from relative to project-based referencing, but I have not found that.

 

Pavel A.
September 3, 2026

Unfortunately the CubeIDE example projects in Cube packages are not easy to move, because they use relative paths within the Cube package - which is insane.

Two ideas: 1. Clone the project to the same parent dir in the Cube package so that all relative links to the library files stay valid. Remove the original project from CubeIDE workspace and import the cloned one.  2. Edit the project manually and convert the relative paths within the Cube package to absolute. Requires some experience with Eclipse CDT, not for beginners :(

 

TDK
September 4, 2026

If it’s an example project, use the example selector in STM32CubeMX to install it at the location of your choice.

"If you feel a post has answered your question, please click ""Accept as Solution""."
DavePfz
DavePfzAuthor
Associate III
September 10, 2026

I tried this, but found that project generated in this case (BLE_HeartRateFreeRTOS for the P-nucleo-WB55) was basically empty. Even after I went through all the steps of specifying the necessary components, it still compiled with warnings! 

DavePfz
DavePfzAuthorBest answer
Associate III
September 13, 2026

After following the various methods proposed by the responders, I found that this procedure works:

First make a new directory in parallel to the existing example project. For example, I took:

C:\ST\STM32Cube_FW_WB_V1.24.0\Projects\P-NUCLEO-WB55.Nucleo\Applications\BLE\BLE_HeartRateFreeRTOS

and made the parallel using my initials to make it different:

C:\ST\STM32Cube_FW_WB_V1.24.0\Projects\P-NUCLEO-WB55.Nucleo\Applications\BLE\DJP_HeartRateFreeRTOS

Copy the files under the old into the new - all of them.

In the new area, find the ioc file and rename it to match the new directory.

Inside the ioc file edit (in text mode) change all occurrences of the old into the new. In my case, there were three occurrences.

At this point you should be able to pull up STM32CubeIDE and compile and run. This is just a check that nothing is broken.

Now pull up STM32CubeMX with the new ioc file. Under the Project Manager → Code Generator tab, select either of the bullets that copy the library files. It is important to remove the “library files as references”. (While there, check that the blocks in the “Generated files” section are what you want. I like the peripheral files as separate ‘c’ and ‘h’ files, but that’s just a personal preference.)

Now, click on [Generate Code], recompile and verify it still works.

At this point, just copy the entire ‘new’ directory structure to wherever you want. Point the tools (MX or IDE) to these new area and it should “Just work.”

Two added notes:

I found that trying to generate the application using MX either required that I fill everything out or one file (hrs_app.c) was corrupt and I had to manually copy it from the original location. For this example, I found using MX was just frustrating!

Also, the same file seems to be affected whenever code is regenerated. This is something that’s beyond me. I haven’t tried this since I moved the project to the new directory, so this may be a fluke.

 

DavePfz
DavePfzAuthor
Associate III
September 16, 2026

I want to add, as per another poster’s recommendation, that the .project file(s) also needs to be edited.

Essentially what I did in the ‘NEW’ area, I edited all instances of ‘OLD’ and replaced them with ‘NEW’. This was true for file names as well as any files containing ‘OLD’.