I want to make a global variable available for the method FPhysSubstepTask::UpdateTime located in ** PhysSubstepTasks.cpp**.
This global variable should switch the behaviour of the method form original to “modified”.
So I have created these two files (with the simple content):
GlobalVariable.h #pragma once
extern int32 Alex;
GlobalVariable.cpp #pragma once
int32 Alex = 3000;
I can #includeGlobalVariable.h in PhysSubstepTask.h
That compiles fine, no problem
But as soon as I use the variable in PhysSubstepTask.cpp
(for example Alex=5)
I get the the following error when I try to compile:
2>C:\Program Files\Unreal Engine Controlled\Engine\Binaries\Win64\UE4Editor-Engine.dll : fatal error LNK1120: 1 unresolved externals
2>UnrealBuildTool : error : UBT ERROR: Failed to produce item: C:\Program Files\Unreal Engine Controlled\Engine\Binaries\Win64\UE4Editor-Engine.dll
2> (see …/Programs/UnrealBuildTool/Log.txt for full exception trace)
The Solution Configuration is set to “Development Editor”
What am I doing wrong here? Any help is most appreciated!
Also instead of use static you can use Config classes, and then retrieve your value with GetDefault<UMyConfig>(); or GetMutableDefault
.H
UCLASS(Config="MyConfig")// this will generate a new config file with this name in the saved/Config/ folder
class MYMODULE_API UMyConfig: public UObject
{
GENERATED_BODY()
public:
UPROPERTY(Config,BlueprintReadOnly, Category = "MyCategory")
int32 Alex;
};
It works fine if I access MyStatics from my project.
If I try to now include it into the PhysSubstepTask.h, I get the error:
*Cannot open include file: ‘MyStatics.h’: No such file or directory *
If I include the MyStatics.h with its complete path into PhysSubstepTask.h, then MyStatics.h it is found but as it contains #include “MyStatics.generated.h” I get the error
cannot open include file: ‘MyStatics.generated.h’: No such file or directory
I have added the path of the sourcefiles of my project to the UE4 VC++Directories:
Hi you have to include your module inside the Engine.Build.cs rules, I’m assuming you are using a custom version, don’t you? otherwise you cannot modify engine stuff that easy
Yes ZkarmaKun, I use the source code Version from github. I can modify the souce code file, that works fine. I just don’t know how to make UE4 check also the directory of my project to find the include files.
My project is on a different hard drive.