I have a class file for example A in the Editor folder in Engine and Class B in Runtime… I need to access a method from Class A in Class B… I included header file #include “A.h”. It is not able to find the file. Could anyone help me with this. .
#include "A.h"
#if WITH_EDITOR || WITH_DEV_AUTOMATION_TESTS
#include "Misc/UObjectToken.h"
#if WITH_DEV_AUTOMATION_TESTS
#include "Misc/AutomationTest.h"
#endif
Class B
{
}
Hi, there! If you question is common, then the thing is smth like that:
Unreal Engine consists of multiple modules. Each module is compiled in a separate build unit. Because of that each module has public things (classes, class methods, etc) and private things (similar to C++ dll). It often depends on what exact class is needed. In most cases, classes in Public folders of modules are exposed and can be used with full force, while those in Private folders are not exposed. However, there are also classes that are exposed partially
If you want to use a class from moudle ModuleA then you need to add this module to your project .Build.cs file to Private or Public Dependencies. Logic here is the same - add it to Public Dependecies if it is used in your headers(.h) and use it in Private Dependencies if it is used only in implementation(.cpp)
For most classes you can find module and header with online Docs, but of couse in source code (for example, AActor | Unreal Engine Documentation)
Thanks for the solution. it totally makes sense exactly what i am looking for… I have added the dependency. Now I got rid of the header file error, but another error popped up linkage error of that function. LNK2019 error… I made sure my function name correct arguments everything…