虚幻 4:未解析的外部符号

Unreal 4: Unresolved external symbols

提问人:Joan Freixas Arnedo 提问时间:2/5/2022 更新时间:2/5/2022 访问量:3263

问:

我刚刚在虚幻4中使用C++(Visual Studio 2019)创建了一个项目。

一旦我仅使用基本移动类生成项目,Visual Studio 就会显示这些错误(见图)。

未解决的外部符号错误

我按照官方指南安装了Visual Studio:https://docs.unrealengine.com/4.27/en-US/ProductionPipelines/DevelopmentSetup/VisualStudioSetup/

这是 cpp 文件中的代码:

// Fill out your copyright notice in the Description page of Project Settings.


#include "MiJugador.h"

// Sets default values
AMiJugador::AMiJugador()
{
    // Set this character to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
    PrimaryActorTick.bCanEverTick = true;

}

// Called when the game starts or when spawned
void AMiJugador::BeginPlay()
{
    Super::BeginPlay();
    
}

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

}

// Called to bind functionality to input
void AMiJugador::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
    Super::SetupPlayerInputComponent(PlayerInputComponent);
    check(PlayerInputComponent);
    PlayerInputComponent->BindAxis("Forward", this, &AMiJugador::MoveForward);
    PlayerInputComponent->BindAxis("Right", this, &AMiJugador::MoveRight);
}

void AMiJugador::MoveForward(float amount)
{
    if (Controller && amount)
    {
        FVector fwd = GetActorForwardVector();
        AddMovementInput(fwd, amount);
    }
}

void AMiJugador::MoveRight(float amount)
{
    if (Controller && amount)
    {
        FVector right = GetActorRightVector();
        AddMovementInput(right , amount);
    }
}

这是头文件:

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Character.h"
#include "MiJugador.generated.h"

UCLASS()
class CPPPRACTICE_API AMiJugador : public ACharacter
{
    GENERATED_BODY()

public:
    // Sets default values for this character's properties
    AMiJugador();

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

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

    // Called to bind functionality to input
    virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;

    // Funciones para movimiento
    void MoveForward(float amount);
    void MoveRight(float amount);
};

大部分代码都是由虚幻引擎自动完成的。任何人都可以帮助我摆脱这些错误吗?这让我发疯了,我尝试了很多事情,比如在项目设置中包含 .lib,但这些都没有帮助我......

提前感谢您抽出宝贵时间接受采访。

C++ 可视化工作室 未解析外部

评论


答:

0赞 Vlad Feinstein 2/5/2022 #1

缺少(或链接器找不到)OpenGL 库。

很可能,你错了。including .lib in project settings

评论

0赞 Joan Freixas Arnedo 2/7/2022
感谢您的回复,库已经包含在内,配置也指向正确的目录。由于某种原因,该项目构建错误或已损坏。我尝试使用完全相同的代码创建另一个项目,它可以工作......我觉得这种奇怪的事情有时会发生......