How do I remove a C++ class from my project code?

There seems to be no way to remove a c++ class from your code after it has been added using the “Add code to project” from the editor.
Running custom compiled UE 4.6
Deleting the .h and .cpp files relating to the class does not do anything at all , you can still see the class in the editor even if you exit and reload the project.

Also It magically opens the header files even after its deletion from the vs solution explorer.

The only way I figured out is that you need to clean your project and rebuild it but in custom compiled engine cleaning the project (“YES I used clean project only”) results in rebuilding the whole editor and engine again which is like compiling 1300+ cpp files for an hour.

This means I have to waste an hour even If I just made a simple spelling mistake in class name in “Add Code to project”

Is there any feasible way to remove a c++ class or at-least to rename it ?


Did you remember to delete every reference of the desired and created class before deleting?, The recration of the class is because of recalling from different modules, and fails, creating a new one. I haven’t tried to delete a class so this is just a guess. Good luck :slight_smile:

My case was the most simple I added a class and realized its not the correct name. I didn’t even used that class before deleting it. Hence absolutely sure it has no reference in my project. I don’t know if it is referenced somewhere in the engine code internally ,but I deleted it right after adding it to add one with a correct name

How did you attempt to delete the class? You realise that deleting files from visual studio solution explorer only removes them from the project, but doesn’t delete them from disk? Since UE has its own project file separate from visual studio, it’s likely in that case that from its point of view, the removal would have no effect. I’d guess you’d have to delete from disk, or at least move them to another path so it can no longer find them.

I did it using the following steps (with UE4.6.1):

  1. close Visual / UE4 Editor
  2. remove the class .cpp and .h from disk in explorer
  3. remove everything in Game\Binaries
  4. run GenerateProjectFiles.bat
  5. open UE4.sln
  6. get back to normal coding activity

If you need to rename a class you can rename the files on disk instead of step 2 and 3 (and then adapt the code to get classname matching filename)

Hope it will work for you too.


Hi Commander Shepard,

The steps provided by Cø should work for you. Step 3 may be optional, though. I have not done this step the few times I have tried to manually delete a code class and I have not run into any problems.

Thx dude :smiley:

Just a note on this:

The above steps work for me as well, however, to delete the class from the Content Browser as well, I had to clean and rebuild my project after step 5 as well (which rebuilds the entire engine unfortunately).

Hi staticvoidlol,

If you need to clean and rebuild your project, and don’t want to have to rebuild the Engine as well, you can delete the Intermediate folder from your project in step 3 in addition to the Binaries folder. Then you would do a normal build of the project in Visual Studio, which will recreate all of the project files that would have been recreated when performing a rebuild, but without rebuilding all of the project’s dependencies (such as the Engine).

The class still being present in the Content Browser after following the steps listed by Cø may not be correct. If you have not already done so, could you please create a new post regarding that issue so we can track and investigate it?

Thanks very much - I’ll try that next time I run into trouble.

I just realized that I should probably clarify something that might be obvious to some users, but perhaps not to everyone who may read this post. After deleting the Binaries and Intermediate folders, you would need to generate project files before opening the solution in Visual Studio and building the project again.

Thanks - I wouldn’t have known that. I probably would’ve tried it at some point though :).

My general practice is:

  1. Remove .h and .cpp file from project
  2. physically delete files from your hard drive
  3. (optional) Perform a clean
  4. Build

Generally deleting the files only removes it from your solution, and I find the some how the build tool still fines any file you just “removed” from the solution (at least that’s my experience). So after removing it from your solution in VS you need to physically delete the files from your source folder.

Now because there is an intermediate folder where some more build tool magic happends I generally perform a clean which ungunks any left over artifacts of the file I just deleted (you can also just delete the intermediate folder). Finally a fresh build (as long as all my references are gone) finishes the job by rebuilding the intermediate folder and generating my dlls.

1 Like

I just ran into this problem again and I can confirm that these steps fix the issue - it originally said something about “Failed to open descriptor file”.

I also deleted everything in the Intermediate folder as suggested by .

Er, any updates on this? Is this still the only way to delete a class…?
I tried to follow this and now my project is essentially broken:

  • Deleted cpp and headerfiles (the only ones I created)
  • Deleted folders ‘Intermediate’, ‘Saved’ and ‘Binaries’
  • Recreated project files
  • Cleaned my game project
  • Tried to rebuild only my game (for some reason it compiles the whole engine instead)
  • Got many horrific compiler errors (cannot post it here due to message length restriction)
  • Tried to open the project from the launcher, had to recompile once more (lasts for about an hour now)
  • Got this message

[21/1322] Link UE4Editor-Core.dll
LINK : fatal error LNK1104: cannot open file ‘D:\Documents\Unreal Projects\VRShowRoom\UE4_Oculus\Engine\Binaries\Win64\UE4Editor-Core.dll’

What have I done… :frowning:

Is there any possiblity to get rid of ALL CUSTOM C++ CODE? I just played around with CPP a few hours to create a custom component (didn’t work) but it sees like I opened the box of pandora…

Hi ,

Just a real quick question for you. Did you delete ALL of the .cpp and .h files from your source folder? Assuming you started with a Blueprint project that you added a custom component class to, you should still have a .h and .cpp file in the source folder that have the same name as your project.

This worked for me but it is really not a good workflow. Should be a lot easier!

Did someone of you feature request that you can delete the C++ class(es) in Unreal Editor’s Content Browser ?

1 Like

How do you “perform a clean” ?

In Visual Studio there is an option under the Build Menu called “Clean Solution”. You can also

  1. Delete the Intermediate Folder in your Project
  2. Right click the UE project and Generate Solution Files.

That will also REALLY clean up things. I actually haven’t needed to perform a clean, really physically deleting the files tends to work. But when it causes hickups when building your solution in VS cleaning usually fixes the problem

Not an answer but I completely agree with you. I have a lot of experience with C++ from work, so I thought it was going to be easy to learn UE, after coming from Unity, but man, there are some things that just don’t make any sense. Almost giving up.

1 Like