Hi There, I am having an issue linking an h file. I am simply adding an include to my HealthComponent.h.
I created the HealthComponent in a folder, outside of the Public/Private folders. It is all working normally otherwise (I have other classes referencing HealthComponent.h with includes). I can’t seem to figure out why this is not working.
I have tried
-
Including the Folder
#include “Assignment1/HealthComponent.h”
-
Not including the folder:
#include “HealthComponent.h”
-
Regenerating the VS project (deleting Binaries/.vs/Intermediate/.sln & Generating).
-
Including the other file in the same folder (BattleController.h) also didn’t work, but I could include .h files either in the base Public folder or in its subfolders.
-
Making sure my folders/files on disk are the same as in the project.
My suspicion is that the Public/Private folder structure is not recognizing the stuff in a folder outside of the Public/Private folder but I was hoping someone could give me some insight.
Reading a bunch of forums about this suggests my best option is probably just deleting the file and creating it again from scratch/copying the code over. I just wanted to see if I was missing something else obvious or if this is some sort of glitch.
In terms of best practices, I guess I should just always use the Public/Private buttons and Not use subfolders when creating C++ files, correct?
I just closed VS, deleted all the regular temp stuff and copied the files into the /Public/Subfolder and /Private/Subfolder and it seems to work.
I am still curious about this because when I created the files originally (without public/private folders) it was able to find them, so it seems like once those folders were added it broke the search path that originally worked. Is there a way to see which files are being searched when the include happens?
Obviously it is doing something extra as it is checking /public & /private when the include is skipping public/private in the #include statement?
Actually I was mistaken, it still is not detecting the file. I thought it was, but it was just because I added a forward declaration.
Now I am getting an error when I try to actually use the Component.
(Output: )
AbilityComponent.h(42): error : Unrecognized type ‘HealthComponent’ - type must be a UCLASS, USTRUCT or UENUM
When I hover over in VS it says
“pointer to incomplete class type “HealthComponent” is not allowed.”
It seems to be sort of finding it because the errors change if I remove the Include, but it doesn’t seem to be properly linking to the class either, since it is not recognizing it. It is a UCLASS as well btw.
How are you creating these files? Are you adding them through VS or are you using the “Add new C++ class” wizard within UE?
I don’t have a direct answer but what I can say is that I’ve had issues in the past attempting to simply add files through VS. I seem to be missing a step that the editor wizard takes care of. That is not to say that it’s not possible to do it all straight from VS but it requires an extra step that isn’t clear to me at this stage. Since then I’ve always just used the wizard rather than fighting it.
EDIT: To be clear, the extra step seemed to be more than just regen’ing the project files. It seemed like maybe I was violating some pre-ordaned/expected file structure/pattern on top of that.
Is there something I am missing about includes here? I created a totally new class HealthComponent2.h , copied everything over. It is in the Source/Project/Public folder. I STILL can’t seem to get a reference to it. It appears to load (since if I change the path to something else it throws an error) however it can’t seem to recognize my object class.
Could this have something to do with the fact that the class calling it is in a folder? This is my latest theory but I am grasping at straws.
I tried creating a new test class to see if it could see the class but it doesn’t seem to find it either.
I think this project file structure is just broken and moving files has somehow permanently torched things.
My next step is to just create a new project and start again from scratch.
Honestly this should have been the simplest task and turned into a nightmare bc of how totally brittle UE is when dealing with C++ files.
I have been adding the newer ones through the editor, I think the issue might be related to the fact that I created some of these files in a subfolder in UE, and perhaps because I moved others around. I’m not sure where this information is being stored but it is not working as expected.
I’m going to try a fresh project and just add things in a more consistent way. Thanks for chiming in though.
I’m going to close this thread down. Lessons I learned:
- Don’t use subfolders when creating files.
- Don’t move files
- Try to use Public/Private folders from init.
- Don’t forget the U before your object name (I think this was the last likely culprit.
For anyone having similar difficulties, I created a new project to test and seemed to have solved the issues on a different thread, so follow up here:
Other Forum Post
Thanks to everyone who weighed in.
Almost a year later while searching this same error (Although in my case it was the Advanced Sessions plugin messing my builds up) and your comment saved me, after reading almost every line of code possible.
Subfolders!!! My Advanced Sessions plugin had unnecessary subfolders, so I brought them to the root of my plugins folder and Voila! I figured it would be a lame overthought causing these issues, and you proved my theory true. Thanks man
If anyone is experiencing issues with an Error Code: 6 involving plugins, ensure their root folders are in the plugins folder, and remove any unnecessary folders. Literally online with my friends in my game right now because of this post.
1 Like