Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

[Closed] 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 ?

Product Version: Not Selected
more ▼

asked Jan 30 '15 at 08:23 AM in C++ Programming

avatar image

Commander Shepard
634 47 71 194

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

The question has been closed Apr 25 '16 at 09:28 PM by Tim C for the following reason:

The question is answered, right answer was accepted

4 answers: sort voted first

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.

more ▼

answered Jan 30 '15 at 11:52 AM

avatar image

1.3k 45 32 101

avatar image Tim C ♦♦ STAFF Feb 02 '15 at 03:40 PM

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.


avatar image staticvoidlol Apr 10 '15 at 08:16 AM

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).

avatar image Tim C ♦♦ STAFF Apr 10 '15 at 02:24 PM

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?


avatar image staticvoidlol Apr 14 '15 at 05:55 AM

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

avatar image Tim C ♦♦ STAFF Apr 14 '15 at 02:22 PM

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.

avatar image staticvoidlol Apr 14 '15 at 03:50 PM

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

avatar image staticvoidlol Apr 17 '15 at 04:05 PM

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 Tim.

avatar image spyro Aug 18 '15 at 05:32 PM

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... :(

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...

avatar image Tim C ♦♦ STAFF Aug 25 '15 at 10:31 PM

Hi spyro,

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.


avatar image Clunk47 Apr 10 '15 at 07:39 AM

Thx dude :D

avatar image crazydaze Mar 14 '16 at 01:54 AM

Where do I get the "generateProjectFiles.bat" from?

avatar image Tim C ♦♦ STAFF Mar 15 '16 at 07:51 PM

Hi crazydaze,

You will actually want to right-click on the .uproject file and select the "Generate Visual Studio project files" option.


(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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 ?

more ▼

answered Feb 02 '16 at 08:43 PM

avatar image

24 2 12 13

avatar image pfjarschel Feb 18 '16 at 05:05 PM

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.

avatar image ArcainOne Feb 24 '16 at 11:15 PM

Don't give up! The biggest issue with learning UE4 from a C++ background is realizing that when you compile there is essentially a new intermediate step as the Build tool runs through your project and processes all the files to create the intermediate code that you do not have to generate for stuff like reflection, and then it builds your code. It took me a good 3-4 months of bugging a lot of people and reading a lot of articles to get a grip on it. But it's worth it...

avatar image Tim C ♦♦ STAFF Mar 04 '16 at 08:43 PM

Hi XenoEgger and pfjarschel,

This was an ability that we had considered implementing about a year ago, but it was deemed to be too risky to add the capability to the Editor.


avatar image Mollrow Mar 06 '16 at 05:12 PM

Really feel like this should get on the road map at some point. Even locking this down to somewhere in the editor options disabled by default with several confirmation steps per class deletion. A good midpoint might be having official documentation for how to do this step. Thanks for helping us understand how to get unblocked! :)

avatar image Furinyx Apr 15 '16 at 07:35 AM

What was the reasoning behind "too risky"? Why would it be risky to allow professional programmers to be able to delete their classes in a few steps as they would when working without an engine editor? I am curious as to what audience Epic is aiming to hand-hold when it comes to C++ programming with UE4.

avatar image Tim C ♦♦ STAFF Apr 25 '16 at 08:46 PM

Hi furinyx,

Unfortunately the process of deleting a code class from a project is not always as simple as deleting a couple files. The Editor would be able to find and remove the header file for the class since that information is available to the Editor. However, even though most class source files use the same name as the header file, this is not a requirement and the Editor may not be able to locate the source file for the class in order to remove it. In addition, class method definitions can technically be found in any file within the module that contains the class. That means the Editor would potentially have to remove lines of code from other files in the module.

Another concern is any remaining references to the class that is being deleted. References in a uasset file (such as a Blueprint) can be flagged by the Editor to let you know that they will need to be corrected. However, any code references to the class will not be found until a build is initiated after the class is deleted. Once a broken code reference looking for the deleted class is found in the build, the project is essentially broken until you manually correct any remaining broken code references.

While it may be theoretically possible to implement a feature allowing a code class to be deleted from the Editor, it would be a very large task to implement an automated system we would not be able to guarantee would work in all situations. The truly unfortunate side effect to this system would be that we would not be able to verify whether the code class was deleted successfully until after it was deleted. The first indication of a problem would likely be when the subsequent build fails. Depending on a user's setup, this may not be something they could recover from.


avatar image Commander Shepard Apr 25 '16 at 08:51 PM

What is all this drama about? A notification every few days about activity on this question. I'm gonna delete this question

avatar image Commander Shepard Apr 25 '16 at 08:53 PM

Looks like I can't even delete it. Admins please lock/delete this question

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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.

more ▼

answered Apr 14 '15 at 04:17 PM

avatar image

430 30 25 50

avatar image XenoEgger Feb 02 '16 at 08:47 PM

How do you "perform a clean" ?

avatar image ArcainOne Feb 04 '16 at 10:48 PM

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

avatar image pfjarschel Feb 18 '16 at 05:21 PM

I just did that and now my level got wiped out as well... Good thing it was just a test level.

avatar image ArcainOne Feb 24 '16 at 11:17 PM

o.O your test level should not have been saved in the intermediate folder... and clean doesn't clean out your content folder. You have essentially deleted your editor and game when you do this, which means when you rebuild it it may take the editor a few minutes to asynchronously load up all the assets in the browser and rebuild textures and materials, so it may "appear" that your level is missing but it should be safely in your content folder... now if you deleted your content folder... I can't help you.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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 :)

more ▼

answered Jan 30 '15 at 08:26 AM

avatar image

61 1 2 2

avatar image Commander Shepard Jan 30 '15 at 08:30 AM

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

avatar image kamrann Jan 30 '15 at 11:45 AM

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.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question