Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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 :

 struct TheStruct
 some property

Im also having a separate cpp file with function defintions


Now i have created a BP Function Library that tries to call USTRUCT Functions:

 class UprojectBPLib : public UBlueprintFunctionLibrary
 void CallFunc1(TheStruct struct);  and in CPP there is a definition { struct.Func1(); }

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)

Product Version: UE 4.21
more ▼

asked Feb 26 '19 at 08:03 AM in C++ Programming

avatar image

3 1 2 4

(comments are locked)
10|2000 characters needed characters left

3 answers: sort voted first

In this case you need #include "projectTypes.h" in the HEADER file (projectBPLib.h).

more ▼

answered Feb 27 '19 at 07:29 AM

avatar image

346 1 4 4

avatar image Dendryt Feb 27 '19 at 08:48 PM

I have all the headers in place

avatar image madturtleGGinin Feb 28 '19 at 12:03 PM

Error suggests that compiler can't find the definition of TheStruct::Func1()

I just found out that if you create .cpp from Visual Studio, the default path will point to "Intermediate". Since you're using a separated .cpp file I'd suggest you checking the path of TheStruct.cpp and make sure it's under Source/[ProjectName]

If this is not the issue, try moving the function definition into TheStruct block first. I know it's not ideal but you need to narrow down the issue.

avatar image Dendryt Mar 02 '19 at 09:45 PM

Yea that fixed it, i forgot that it by default creates files in intermediate. Thanks!

(comments are locked)
10|2000 characters needed characters left

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).

more ▼

answered Feb 28 '19 at 09:45 AM

avatar image

35.2k 921 166 1098

(comments are locked)
10|2000 characters needed characters left

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).

more ▼

answered Feb 27 '19 at 09:08 PM

avatar image

36 2 6

avatar image Dendryt Feb 27 '19 at 09:27 PM

Hey, i wrote that i presented you a simplified code. What i have in my project is working correctly until i try to call USTRUCT functions from Blueprint Function Library

avatar image XevotPhoenix Feb 27 '19 at 10:47 PM

Basically the error says that the linker failed to locate the definition of the struct member function. The problem is in the thestruct.h or in the thestruct.cpp somewhere, but it shows up only when you actually call the missing definition.

avatar image Dendryt Feb 28 '19 at 09:19 AM

I tried all the weird combination of includes, to make sure compiler knows about everything - nothing seems to work here. VS is finding all definitions properly from wherever i navigate to them.

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question