Intermediate Folder

What is the purpose of the Intermediate folder?

I wanted to exclude a .h and .cpp file from my project, so I did that in visual studio. From there, I couldn’t find them in my public and private folders.

When I tried to make new files with the same names as the ones I had excluded, Visual Studio threw this error:

A file with the same name [path to file, in intermediate folder] already appears on disk.

Why did the files get moved to this folder?

Thanks

Hi Dave,

This question has been asked by another user before. The answer can be found here: https://rocket.unrealengine.com/questions/2201/c-why-are-files-put-in-the-intermediate-folder.html

Here is what Mike Fricker said about the intermediate folder:

When you’re creating new C++ classes in Visual Studio, you’ll need to take note of where they’re placed. You definitely do not want to save them under the Intermediate folder. That will only lead to sadness. Here is the general idea:

If you plan you declare UObjects or UStructs in your header file (.h), you’ll need to make sure its saved under the Classes sub-folder for your game module. This is so that UnrealHeaderTool will be able to locate these headers, parse them, and automatically generate additional C++ code for those classes. For example:

/Source//Classes/MyUObject.h

Most of your other non-UObject C++ header files (.h) should go in your module’s Private folder. This is just where we put source files and headers that aren’t exposed to other (sibling) modules.

/Source//Private/MyGameFeature.h

All of your game’s C++ source files (.cpp) should go into your module’s Private folder. Source files are never “public”.

/Source//Private/MyGameFeature.cpp

You may decide to use multiple C++ modules (.dll’s) for your game. If you do, then you can place classes in a Public folder to allow your game module’s sibling modules to access those APIs, or vice-versa. This is a more complicated use case that I can elaborate more on if you want. Also note that currently, all files in the “Classes” folder are also considered Public, even though most of the time they will only be used in the module that declared the class. An example of a publically exposed header would be:

/Source//Public/MyPublicAPI.h

Let me know if you have any more questions like this!

–Mike

I hope that this has helped to answer your question. If there is anything else that needs clarification, please let me know.

Cheers!

Alexander

Thanks Alexander.

That was very thorough and definitely cleared things up for me.

Just in case it was still unclear, the Intermediate folder is where, for lack of a better term, “intermediary” files go.

For example, the C++ .cpp and .h files are compiled into object files (.obj), and then eventually these are linked and packaged into .dll files (a form of executable code). The .obj files are a step in the middle of the process, and they are put in the Intermediate folder. Nothing in the intermediate folder should be permanent (you shouldn’t put .h or .cpp files or anything you want to keep in there), and even if the Intermediate folder is deleted, it should just be recreated when you build again.

Doing a “clean” or “rebuild” in visual studio should delete and recreate parts of the intermediate folder that are related to the current project, platform, and build configuration. If you are trying to delete c++ files and create new ones with the same name, you will most likely have to do a clean or rebuild in visual studio.

3 Likes

Great answer Joe, thanks for the clarity. This was very helpful to understand the process.

Going to C++ (at least, with the Unreal related stuff) has a bit of a learning curve when I’ve been doing web and C# for so long.