Hello. I am currently making a game, based entirely on Blueprints(except maybe some plugins i did not wrote). I want to start using C++ in a project to implement some functionality that I can’t implement with Blueprints, and later on, to optimize the current code in Blueprints.
I’ve looked through enough pages on the forum and YouTube videos, and realized that to convert the project from Blueprints-only I only need to make a C++ class.
I click Tools-> New C++ Class → choose “Blueprint Function Library” (at the moment, this is what I need) → Class type is public, I don’t change the name and path → click “Create Class”. Visual Studio 2022 opens, *.cpp and *.h files are created, and then the project starts compiling changes for Live Coding.
And the build fails. Live Coding console writes the following error:
fatal error C1083: Cannot open include file: ‘gamename.h’: No such file or directory
It should also be noted that BEFORE adding my own C++ class - everything compiles fine, without errors.
I am at a complete loss as I am new to C++ and have tried everything I can. Can someone tell me what options there are for solving this problem? I will be extremely grateful.
Also, I can provide more information on request if it will help to solve the problem. If I find out something myself, I will add to the post.
I am pretty new to this and struggling to do basic stuff in VS for UE but I believe you cannot compile in VS while Live coding is enabled. Try disabling it in the UE editor. before you do changes to your VS project Editor Settings-> Live coding.
I’ve deleted class that I’ve made, turned off Live Coding.
Tried to add it again, and it says:
Successfully added class ‘MyBlueprintFunctionLibrary’, however you must recompile the ‘gamename’ module before it will appear in the Content Browser. Failed to automatically compile the ‘gamename’ module.
In output log there is still the same error:
fatal error C1083: Cannot open include file: ‘gamename.h’: No such file or directory
I think i need to find somewhere file ‘gamename.h’, or create it, or something… I don’t know exactly.
Note: I prefer to write “gamename” instead of actual name of my project
in this thread. So “gamename” is basically how my project called.
Note 2: ‘gamename.h’ actually exists in Source folder, it seems like compiler doesn’t see it or smth.
Note 3: When im trying to build solution in VS 2022, ‘gamename.h’ responds with error ‘cannot open source file “CoreMinimal.h”’, error code E1696
Note 3.1: I fixed issue with CoreMinimal.h thing, i guess. Found solution here
I found that thing will not work unless you name things as UE expects them.
The filename and class name must be identical. You must include a line with a classname.generated.h and annotate your class appropriately. Here is a hello project that works for me try it out.
Header:
// Fill out your copyright notice in the Description page of Project Settings.
Also I have noticed sometimes you need to build twice for it to work because the first pass generated the generated.h file so it is not there until the second pass. Maybe I am missing something but this my experienc3e.
I guess it problably will work, but I fixed it by including hard link to file (“D:/game/etc.” instead of just the name like “gamename.h”).
Maybe not the best solution to the problem, but if it works - its fine I guess?
PrivateDependencyModuleNames.AddRange(new string [] { });
PublicIncludePaths.AddRange(new string []
{
//below you need to type path to your folder where class is AFTER folder "Source".
//NOT name of the project. Name of the FOLDER where your classes
"game/"
});
The name of the first folder after Source should be enough. If not, take the path all the way like
"game/",
"game/inventory/"
A comma is only needed if you have several such paths. The last path in the list must be without a comma.
Then save, close, go to project folder, RMB on .project file, pick “Generate Visual Studio Project Files”.
If it’s good, then open VS and try to build project and after that try to create class in Editor.