x

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"

UFUNCTION cause missing link error

Hello everyone,

I'm trying to implement a function (in a UActorComponent) that from a string returns an array of textures.

Header:

 UFUNCTION(BlueprintCallable, Category = "CameraDirector")
 TArray<UTexture> GetFrames(FName shotSize);

implementation:

 TArray<UTexture> GetFrames(FName shotSize)
 {
     TArray<UTexture> frames;
     //TArray<FStringAssetReference>& shotSizeArray = cameraAngles[shotSize];
     //FStreamableManager& Streamable = UDMLSingleton::Get().AssetLoader;
 
     //for (auto& assetReference : shotSizeArray)
     //{
     //    //frames.Add(Cast<UTexture> (Streamable.SynchronousLoad(assetReference)));
     //}
     
     return frames;
 }

As you may see the the function is almost all commented, because I immeditely got a compile error and I wanted to have the bare minimum to avoid confusion.

Th error:

 MyProjectPath/Source/unreal_myproject/CmpntCameraDirector.h(25) : Missing '*' in Expected a pointer type
 Error : Failed to generate code for unreal_myprojectEditor - error code: OtherCompilationError (5)

I searched the error here in the hub, but I found answers that contraddict each other. Here and here is said that the use of pointers is forbidden. Here instead is accepted an answer that propose as solution to use a pointer!

I decided to go for the second solution (I was not using pointers in the first place) and I don't get that error anymore, but I got a new one.

New method signature:

 UFUNCTION(BlueprintCallable, Category = "CameraDirector")
 TArray<UTexture*> GetFrames(FName shotSize);

New error:

 CmpntCameraDirector.cpp.obj : error LNK2019: unresolved external symbol "public: class TArray<class UTexture *,class FDefaultAllocator> __cdecl UCmpntCameraDirector::GetFrames(class FName)" (?GetFrames@UCmpntCameraDirector@@QEAA?AV?$TArray@PEAVUTexture@@VFDefaultAllocator@@@@VFName@@@Z) referenced in function "public: void __cdecl UCmpntCameraDirector::execGetFrames(struct FFrame &,void * const)" (?execGetFrames@UCmpntCameraDirector@@QEAAXAEAUFFrame@@QEAX@Z)
 unreal_myproject.generated.cpp.obj : error LNK2001: unresolved external symbol "public: class TArray<class UTexture *,class FDefaultAllocator> __cdecl UCmpntCameraDirector::GetFrames(class FName)" (?GetFrames@UCmpntCameraDirector@@QEAA?AV?$TArray@PEAVUTexture@@VFDefaultAllocator@@@@VFName@@@Z)
 MyProjectPath\Binaries\Win64\UE4Editor-unreal_dontmakelove-494.dll : fatal error LNK1120: 1 unresolved externals

Apparently the problem is connected to TArray, because for test purpose I changed the function to return an array of FString and I got the same error.

It's important to notice that if I don't use UFUNCTION I don't get any error. I'm new to C++ (even though I'm learning it, and I know Java and C#) so probably I'm missing something here, but I really need to have this function accessible from blueprint.

Any suggestion?

Product Version: UE 4.11
Tags:
more ▼

asked Apr 08 '16 at 06:25 PM in C++ Programming

avatar image

Maggese
55 4 6 9

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Your implementation is missing class name. It should be:

 TArray<UTexture*> YourActorComponentName::GetFrames(FName shotSize)
 {
     // Do stuff...
 }
more ▼

answered Apr 08 '16 at 07:58 PM

avatar image

ryanjon2040
1.6k 56 43 93

avatar image Maggese Apr 09 '16 at 06:39 PM

This is really embarassing, probably I need an eye doctor XD Thanks a lot!

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
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