CPP Blueprint Function Library and USTRUCTS functions problems
Im trying to use BlueprintFunctionLibrary written in cpp to get access to functions inside USTRUCT, and i struggled into this type of problem:
I have a USTRUCT defined with some functions inside:
Example in simplified code :
Im also having a separate cpp file with function defintions
Now i have created a BP Function Library that tries to call USTRUCT Functions:
After having such a setup, the project doesnt compile, it throws Unresolved External Symbol error with Func1()
ERROR MESSAGE: UprojectBPLib.cpp.obj : error LNK2019: unresolved external symbol "public: void __cdecl TheStruct::Func1()" (?Func1@TheStruct@@QEAAXW4Level@TheStruct@@N@Z) referenced in function "private: static void _cdecl UprojectBPLib::Func1()" (?Func1@UprojectBPLib@@CAXUFTheStruct@@W4Level@ETheStruct@@_N@Z)
In this case you need
answered Feb 27 '19 at 07:29 AM
My closesed guess is that cpp is not even seen by UnrealBuildTool, because the way you have thigns now UnrealHeaderTool should scream from errors you made in header file as described by XevotPhoenix.
Make sure file is located properly, if you added file in VS file manage, it most likely landed in Intermediate\ProjectFiles insted of Source where UBT don't look (VS project is not used by UBT at all, it only exist for VS IDE for file editing), as VS sets that as default project directory. IF so, move those file (not with VS, explorer or whatever file manager oyu use) to Source directory to there proper locations and regenerate project files
It is always safest to create files in Source manually and regenerate project files, or at least make sure you add files in proper location (VS let you choose file creation location).
First, USTRUCT needs a GENERATED_BODY() inside its declaration. Second, its name must begin with the letter 'F'. Also, you need to include the *.generated.h header file (where in * you place the name of the header file that contains the struct definition).
Follow this question
Once you sign in you will be able to subscribe for any updates here