如何在我的虚幻项目中修复“符号查找错误”?

时间:2019-09-06 07:52:29

标签: c++ unreal-engine4

我试图用虚幻引擎C ++编写Actor,该Actor从渲染目标获取纹理数据。

我有一个演员课:

#include "RenderActor.h"
#include "Engine.h"
#include <stdio.h>

// Sets default values
ARenderActor::ARenderActor()
{
    // Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
    PrimaryActorTick.bCanEverTick = true;
    UE_LOG(LogTemp, Warning, TEXT("Init RenderActor\n"));
}

// Called when the game starts or when spawned
void ARenderActor::BeginPlay()
{
    Super::BeginPlay();
    UE_LOG(LogTemp, Warning, TEXT("BeginPlay RenderActor\n"));

    UTextureRenderTarget2D* target = GetTextureByName(TEXT("MyCanvas"));

}

// Called every frame
void ARenderActor::Tick(float DeltaTime)
{
    Super::Tick(DeltaTime);
}

UTextureRenderTarget2D* GetTextureByName(const TCHAR* name)
{
    return LoadObject<UTextureRenderTarget2D>(NULL, name, NULL, LOAD_None, NULL);
}

int ARenderActor::GetTextureData(UTextureRenderTarget2D* TextureRenderTarget ,void* out_ptr,int length)
{
    int sx=TextureRenderTarget->SizeX,sy=TextureRenderTarget->SizeY;
    TArray<FColor> SurfData;
    FRenderTarget *renderTarget = TextureRenderTarget->GameThread_GetRenderTargetResource();
    check((sx*sy*4)<=length);
    renderTarget->ReadPixels(SurfData);
    memcpy(out_ptr,reinterpret_cast<void*>(SurfData.GetData()),sx*sy*4);
    return sx*sy*4;
}

下面有一个.h:

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "Runtime/Engine/Classes/Components/WindDirectionalSourceComponent.h"
#include "Runtime/Engine/Classes/Engine/WindDirectionalSource.h"
#include "Runtime/CoreUObject/Public/UObject/UObjectBaseUtility.h"
#include "Runtime/CoreUObject/Public/UObject/UObjectGlobals.h"
#include "Runtime/Engine/Classes/Engine/TextureRenderTarget2D.h"
#include "RenderActor.generated.h"

UCLASS()
class MEMRENDER_API ARenderActor : public AActor
{
    GENERATED_BODY()

public: 
    // Sets default values for this actor's properties
    ARenderActor();

protected:
    // Called when the game starts or when spawned
    virtual void BeginPlay() override;

public: 
    // Called every frame
    virtual void Tick(float DeltaTime) override;

    UTextureRenderTarget2D* GetTextureByName(const TCHAR* name);

    int GetTextureData(UTextureRenderTarget2D* TextureRenderTarget ,void* out_ptr,int length);

};

现在我可以在Ubuntu 18.04上对其进行编译,但是会遇到运行时错误:

/home/starrabb1t/UnrealEngine/Engine/Binaries/Linux/UE4Editor: symbol lookup error: /home/starrabb1t/Documents/Unreal Projects/MemRender/Binaries/Linux/libUE4Editor-MemRender-7856.so: undefined symbol: _ZN12ARenderActor16GetTextureByNameEPKDs

P.S:我有一个带有RenderActor对象的场景。我还在内容目录的根目录中创建了渲染目标MyCanvas。

0 个答案:

没有答案