【问题标题】:Unreal Engine 4.21.2 & Squareys CISQLite3 Plugin Compile Issues虚幻引擎 4.21.2 和 Squareys CISQLite3 插件编译问题
【发布时间】:2019-08-17 13:16:17
【问题描述】:

我正在尝试将 SQLite3 集成到我在 UE4 中的测试项目中,但我遇到了一些问题。

首先是一些家务。链接到 GitHub 上的 repo,Square 的插件是旧 CISQLite3 插件的分叉和更新版本:

https://github.com/Squareys/unreal-sqlite3

接下来,我使用的项目是一个蓝图项目,其中包含从编辑器中创建的自定义类。

安装步骤: 我遵循了 repo 的自述文件中的安装指南,其中说明了以下内容:

下载插件 zip 并将其解压缩到您的项目插件文件夹中。打开编辑器并转到插件管理器并启用插件。重启并允许编辑器编译插件。

在 4.20.x 中,这显然是所有需要的。无论出于何种原因,在 4.21.2 中这个过程都被破坏了。我遇到了与生成的文件有关的各种问题。

所以对于我所尝试的: 我已经尝试在插件中间文件夹中给出生成文件的绝对路径 - 这只是允许编译器像来自地狱的老忠实一样吐出错误。

我尝试过开始一个新项目;三次。由于稍后我将在帖子中提出的错误,我总是遇到无法继续前进的地步。

我尝试在删除 .vs、二进制文件、中间文件和已保存文件夹后重新生成项目文件。有时重建可以重新创建文件(不能解决问题),但在某些时候它开始失败,当我打开项目时,它将无法编译项目 dll/lib 并说要手动编译。

好的,继续讨论实际的错误。我将逐步引导您完成并在我执行的每个调试步骤中显示错误。

首先,即使在没有自定义代码的新项目中,我也会收到以下两个警告:

MiningTechDemo5\Plugins\CISQLite3\Source\CISQLite3\CISQLite3.Build.cs:警告:从 UE 4.21 开始,模块必须指定一个明确的预编译标头(例如 PrivatePCHHeaderFile = "Private/CISQLite3PrivatePCH.h")。

MiningTechDemo5\Plugins\CISQLite3\Source\CISQLite3\CISQLite3.Build.cs:警告:引用目录 'F:\UE4\Epic Games\UE_4.21\Engine\Source\CISQLite3\Public' 不存在。

为了解决这个问题,我将插件构建文件更改为:

// Copyright (c) 2015 Jussi Saarivirta 2016 conflict.industries MIT License (MIT)

using UnrealBuildTool;

public class CISQLite3 : ModuleRules
{
  public CISQLite3(ReadOnlyTargetRules Target) : base(Target)
  {

    PublicIncludePaths.AddRange(
      new string[] {
        "F:/UE4/Projects/MiningTechDemo5/Plugins/CISQLite3/Source/CISQLite3/Public"
      }
    );

    PrivateIncludePaths.AddRange(
      new string[] {
        "F:/UE4/Projects/MiningTechDemo5/Plugins/CISQLite3/Source/CISQLite3/Private"
      }
    );

    PublicDependencyModuleNames.AddRange(
      new string[] {
        "Engine",
        "Core",
        "CoreUObject"
      }
    );

    PrivateDependencyModuleNames.AddRange(
      new string[] {}
    );

    DynamicallyLoadedModuleNames.AddRange(
      new string[] {}
    );
  }
}

我必须使用绝对路径,因为出于某种原因 ModuleDirectory 只指向我的 F:\ 驱动器而不是项目/插件文件夹。所以,这些错误现在已经消失了。一切似乎都很好,直到我将 SQLiteDatabase.h 包含到我的 DatabaseHandler 自定义类(在编辑器中创建)中。

我得到的第一个错误是找不到 DatabaseHandler.generated.h,但这是因为找不到 SQLiteDatabase.h 的第二个错误。所以我认为,这可能与 CISQLite3 构建文件的问题相同,我将我的项目构建文件从默认生成的代码更改为:

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

using UnrealBuildTool;

public class MiningTechDemo5 : ModuleRules
{
    public MiningTechDemo5(ReadOnlyTargetRules Target) : base(Target)
    {
        PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
    
        PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" });

        PrivateDependencyModuleNames.AddRange(new string[] {  });

        PrivateIncludePaths.Add("F:/UE4/Projects/MiningTechDemo5/Plugins/CISQLite3/Source/CISQLite3/Private");
        PublicIncludePaths.Add("F:/UE4/Projects/MiningTechDemo5/Plugins/CISQLite3/Source/CISQLite3/Public");
        PublicLibraryPaths.Add("F:/UE4/Projects/MiningTechDemo5/Binaries/Win64");

        // Uncomment if you are using Slate UI
        // PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });
        
        // Uncomment if you are using online features
        // PrivateDependencyModuleNames.Add("OnlineSubsystem");

        // To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true
    }
}

再一次,完整的路径,因为 ModuleDirectory 不起作用,Path.Combine 也不起作用;至少不会使用将路径的一部分作为帮助成员返回的字符串属性,因此输入的文本更少。

所以我重建,同样的错误。我继续将包含更改为绝对路径:

包括“SQLiteDatabase.h”

到这里:

包括“F:/UE4/Projects/MiningTechDemo5/Plugins/CISQLite3/Source/CISQLite3/Public/SQLiteDatabase.h”

重新编译。 Huzzah,没有错误。废话,因为现在有一个新的错误。这个是针对 SQLiteBlueprintNodes.h 文件的:

无法打开包含文件:'SQLiteBlueprintNodes.generated.h':没有这样的文件或目录

好的,所以我绝对路径它:

包括“F:/UE4/Projects/MiningTechDemo5/Plugins/CISQLite3/Intermediate/Build/Win64/UE4Editor/Inc/CISQLite3/SQLiteBlueprintNodes.generated.h”

此时,编译器获取生成的文件并用一堆编译器 barf 和一个新生成的文件未找到 SQLiteDatabaseStructs.generated.h 的错误:

'FSQLiteQueryLogicExpectedNode' uses undefined struct 'CISQLITE3_API'   8

'friend': not allowed outside of a class definition 9
type 'Z_Construct_UScriptStruct_FSQLiteQueryLogicExpectedNode_Statics' unexpected   9

missing type specifier - int assumed. Note: C++ does not support default-int    14

'FSQLiteQueryLogicExpectedNode': redefinition; previous definition was 'data variable'  14

missing type specifier - int assumed. Note: C++ does not support default-int    15

'FSQLiteQueryLogicExpectedNode': redefinition; previous definition was 'data variable'  15

'FSQLiteQueryLogicExpectedNode': constructor initializer lists are only allowed on constructor definitions  16

syntax error: '}'   19

syntax error: missing ';' before '}'    19

'FSQLiteQueryTermExpectedNode' uses undefined struct 'CISQLITE3_API'    23

'friend': not allowed outside of a class definition 24

type 'Z_Construct_UScriptStruct_FSQLiteQueryTermExpectedNode_Statics' unexpected    24

'FString Query': redefinition   27

'void __cdecl `dynamic initializer for 'Query''(void)': constructor initializer lists are only allowed on constructor definitions   27

missing type specifier - int assumed. Note: C++ does not support default-int    29

'FSQLiteQueryTermExpectedNode': redefinition; previous definition was 'data variable'   29

missing type specifier - int assumed. Note: C++ does not support default-int    30

'FSQLiteQueryTermExpectedNode': redefinition; previous definition was 'data variable'   30

'FSQLiteQueryTermExpectedNode': constructor initializer lists are only allowed on constructor definitions   31

syntax error: '}'   34

syntax error: missing ';' before '}'    34

'FSQLiteQueryFinalizedQuery' uses undefined struct 'CISQLITE3_API'  38

'friend': not allowed outside of a class definition 39

type 'Z_Construct_UScriptStruct_FSQLiteQueryFinalizedQuery_Statics' unexpected  39

'FString Query': redefinition   42

'void __cdecl `dynamic initializer for 'Query''(void)': constructor initializer lists are only allowed on constructor definitions   42

missing type specifier - int assumed. Note: C++ does not support default-int    44

'FSQLiteQueryFinalizedQuery': redefinition; previous definition was 'data variable' 44

missing type specifier - int assumed. Note: C++ does not support default-int    45

'FSQLiteQueryFinalizedQuery': redefinition; previous definition was 'data variable' 45

'FSQLiteQueryFinalizedQuery': constructor initializer lists are only allowed on constructor definitions 45

syntax error: '}'   46

syntax error: missing ';' before '}'    46

Cannot open include file: 'SQLiteDatabaseStructs.generated.h': No such file or directory    2

对于我使用绝对路径生成的每个文件,我都会收到所有这些相同的错误,以及一个额外的生成文件错误,直到我返回 SQLiteDatabase.h。当我生成文件的绝对路径时,这是我得到的新错误:

标题顶部应包含一个包含:'#include "SQLiteDatabase.generated.h"'

为简洁起见,我将包括上面提到的所有文件及其生成的文件,如果它们抛出错误,如下所示:

SQLiteBlueprintNotes.h:

#pragma once
#include "F:/UE4/Projects/MiningTechDemo5/Plugins/CISQLite3/Intermediate/Build/Win64/UE4Editor/Inc/CISQLite3/SQLiteBlueprintNodes.generated.h"


USTRUCT(BlueprintType)
struct CISQLITE3_API FSQLiteQueryLogicExpectedNode
{
    GENERATED_USTRUCT_BODY()

    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SQLite Database Query")
    FString Query;

    FSQLiteQueryLogicExpectedNode(){}
    FSQLiteQueryLogicExpectedNode(FString LHSQuery, FString Append) : Query(LHSQuery)
    {
        Query += Append;
    }
};

USTRUCT(BlueprintType)
struct CISQLITE3_API FSQLiteQueryTermExpectedNode
{
    GENERATED_USTRUCT_BODY()

    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SQLite Database Query")
    FString Query;

    FSQLiteQueryTermExpectedNode(){}
    FSQLiteQueryTermExpectedNode(FString LHSQuery, FString Append) : Query(LHSQuery)
    {
        Query += Append;
    }
};

USTRUCT(BlueprintType)
struct CISQLITE3_API FSQLiteQueryFinalizedQuery
{
    GENERATED_USTRUCT_BODY()

    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SQLite Database Query")
    FString Query;

    FSQLiteQueryFinalizedQuery(){}
    FSQLiteQueryFinalizedQuery(FString Query) : Query(Query){}
};

SQLiteBlueprintNodes.generated.h:

// Copyright 1998-2018 Epic Games, Inc. All Rights Reserved.
/*===========================================================================
    Generated code exported from UnrealHeaderTool.
    DO NOT modify this manually! Edit the corresponding .h files instead!
===========================================================================*/

#include "UObject/ObjectMacros.h"
#include "UObject/ScriptMacros.h"

PRAGMA_DISABLE_DEPRECATION_WARNINGS
#ifdef CISQLITE3_SQLiteBlueprintNodes_generated_h
#error "SQLiteBlueprintNodes.generated.h already included, missing '#pragma once' in SQLiteBlueprintNodes.h"
#endif
#define CISQLITE3_SQLiteBlueprintNodes_generated_h

#define MiningTechDemo5_Plugins_CISQLite3_Source_CISQLite3_Public_SQLiteBlueprintNodes_h_39_GENERATED_BODY \
    friend struct Z_Construct_UScriptStruct_FSQLiteQueryFinalizedQuery_Statics; \
    static class UScriptStruct* StaticStruct();


#define MiningTechDemo5_Plugins_CISQLite3_Source_CISQLite3_Public_SQLiteBlueprintNodes_h_24_GENERATED_BODY \
    friend struct Z_Construct_UScriptStruct_FSQLiteQueryTermExpectedNode_Statics; \
    static class UScriptStruct* StaticStruct();


#define MiningTechDemo5_Plugins_CISQLite3_Source_CISQLite3_Public_SQLiteBlueprintNodes_h_9_GENERATED_BODY \
    friend struct Z_Construct_UScriptStruct_FSQLiteQueryLogicExpectedNode_Statics; \
    static class UScriptStruct* StaticStruct();


#undef CURRENT_FILE_ID
#define CURRENT_FILE_ID MiningTechDemo5_Plugins_CISQLite3_Source_CISQLite3_Public_SQLiteBlueprintNodes_h


PRAGMA_ENABLE_DEPRECATION_WARNINGS

SQLiteDatabaseStructs.h:

#pragma once
#include "F:/UE4/Projects/MiningTechDemo5/Plugins/CISQLite3/Intermediate/Build/Win64/UE4Editor/Inc/CISQLite3/SQLiteDatabaseStructs.generated.h"

USTRUCT(BlueprintType)
struct CISQLITE3_API FSQLiteIndex
{
    GENERATED_USTRUCT_BODY()

        /** String with piece if SQL script*/
        UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SQLite Index")
        FString ResultStr = "";

    /** Index name*/
    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SQLite Index")
        FString IndexName = "";

};

USTRUCT(BlueprintType)
struct CISQLITE3_API FSQLitePrimaryKey
{
    GENERATED_USTRUCT_BODY()

        /** String with piece if SQL script*/
        UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SQLite Primary Key")
        FString ResultStr = "";
};

USTRUCT(BlueprintType)
struct CISQLITE3_API FSQLiteTableField
{
    GENERATED_USTRUCT_BODY()

        /** String with piece if SQL script*/
        UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SQLite Table Field")
        FString ResultStr = "";

    /** Field name*/
    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SQLite Table Field")
        FString FieldName = "";

    /** Field type*/
    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SQLite Table Field")
        FString FieldType = "";

    /** Field value*/
    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SQLite Table Field")
        FString FieldValue = "";

};

USTRUCT(BlueprintType)
struct CISQLITE3_API FSQLiteTableRowSimulator
{
    GENERATED_USTRUCT_BODY()

        /** Index name*/
        UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SQLite Index")
        TArray<FSQLiteTableField> rowsOfFields;

};

USTRUCT(BlueprintType)
struct CISQLITE3_API FSQLiteTable
{
    GENERATED_USTRUCT_BODY()

        /** Database name*/
        UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SQLite Table")
        FString DatabaseName = "";

    /** Table name*/
    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SQLite Table")
        FString TableName = "";

    /** Array with Fields*/
    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SQLite Table")
        TArray<FSQLiteTableField> Fields;

    /** Primary Key */
    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SQLite Table")
        FSQLitePrimaryKey PK;

    /** Created Key */
    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SQLite Table")
        bool Created = false;

};

SQLiteDatabaseStructs.generated.h:

// Copyright 1998-2018 Epic Games, Inc. All Rights Reserved.
/*===========================================================================
    Generated code exported from UnrealHeaderTool.
    DO NOT modify this manually! Edit the corresponding .h files instead!
===========================================================================*/

#include "UObject/ObjectMacros.h"
#include "UObject/ScriptMacros.h"

PRAGMA_DISABLE_DEPRECATION_WARNINGS
#ifdef CISQLITE3_SQLiteDatabaseStructs_generated_h
#error "SQLiteDatabaseStructs.generated.h already included, missing '#pragma once' in SQLiteDatabaseStructs.h"
#endif
#define CISQLITE3_SQLiteDatabaseStructs_generated_h

#define MiningTechDemo5_Plugins_CISQLite3_Source_CISQLite3_Public_SQLiteDatabaseStructs_h_66_GENERATED_BODY \
    friend struct Z_Construct_UScriptStruct_FSQLiteTable_Statics; \
    static class UScriptStruct* StaticStruct();


#define MiningTechDemo5_Plugins_CISQLite3_Source_CISQLite3_Public_SQLiteDatabaseStructs_h_55_GENERATED_BODY \
    friend struct Z_Construct_UScriptStruct_FSQLiteTableRowSimulator_Statics; \
    static class UScriptStruct* StaticStruct();


#define MiningTechDemo5_Plugins_CISQLite3_Source_CISQLite3_Public_SQLiteDatabaseStructs_h_32_GENERATED_BODY \
    friend struct Z_Construct_UScriptStruct_FSQLiteTableField_Statics; \
    static class UScriptStruct* StaticStruct();


#define MiningTechDemo5_Plugins_CISQLite3_Source_CISQLite3_Public_SQLiteDatabaseStructs_h_22_GENERATED_BODY \
    friend struct Z_Construct_UScriptStruct_FSQLitePrimaryKey_Statics; \
    static class UScriptStruct* StaticStruct();


#define MiningTechDemo5_Plugins_CISQLite3_Source_CISQLite3_Public_SQLiteDatabaseStructs_h_7_GENERATED_BODY \
    friend struct Z_Construct_UScriptStruct_FSQLiteIndex_Statics; \
    static class UScriptStruct* StaticStruct();


#undef CURRENT_FILE_ID
#define CURRENT_FILE_ID MiningTechDemo5_Plugins_CISQLite3_Source_CISQLite3_Public_SQLiteDatabaseStructs_h


PRAGMA_ENABLE_DEPRECATION_WARNINGS

SQLiteDatabase.h:

#pragma once
#include "sqlite3.h"
#include "SQLiteBlueprintNodes.h"
#include "SQLiteDatabaseStructs.h"
#include "F:/UE4/Projects/MiningTechDemo5/Plugins/CISQLite3/Intermediate/Build/Win64/UE4Editor/Inc/CISQLite3/SQLiteDatabase.generated.h"

USTRUCT(BlueprintType)
struct CISQLITE3_API FSQLiteDatabaseReference
{
    GENERATED_USTRUCT_BODY()

        /** The database name (not the filename) */
        UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SQLite Database Reference")
        FString DatabaseName;

    /** The database tables we want to get data from */
    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SQLite Database Reference")
        TArray<FString> Tables;
};

USTRUCT(BlueprintType)
struct CISQLITE3_API FSQLiteKeyValuePair
{
    GENERATED_USTRUCT_BODY()

        /** The database table field name */
        UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SQLite Key Value Pair")
        FString Key;

    /** The value of the field */
    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SQLite Key Value Pair")
        FString Value;
};

USTRUCT(BlueprintType)
struct CISQLITE3_API FSQLiteQueryResultRow
{
    GENERATED_USTRUCT_BODY()

        /** A list of field name, field value pairs */
        UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SQLite Query Result")
        TArray<FSQLiteKeyValuePair> Fields;
};

USTRUCT(BlueprintType)
struct CISQLITE3_API FSQLiteQueryResult
{
    GENERATED_USTRUCT_BODY()

        /** The resulting rows from the query */
        UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SQLite Query Result")
        TArray<FSQLiteQueryResultRow> ResultRows;

    /** Was the query successful or not */
    UPROPERTY(BlueprintReadOnly, Category = "SQLite Query Result")
        bool Success;

    /** If the query was unsuccessful a human readable error message will be populated here */
    UPROPERTY(BlueprintReadOnly, Category = "SQLite Query Result")
        FString ErrorMessage;

};



// A few things for internal use here.
namespace SQLiteResultValueTypes
{
    enum SQLiteResultValType
    {
        Integer,
        Float,
        Text,
        UnsupportedValueType
    };
}

// Result field, used as an intermediary when collecting results from
// an SQLITE3 query.
struct SQLiteResultField
{
    FString StringValue;
    double DoubleValue;
    int64 IntValue;

    FString Name;
    SQLiteResultValueTypes::SQLiteResultValType Type;

    FString ToString()
    {
        if (Type == SQLiteResultValueTypes::Text)
            return StringValue;
        else if (Type == SQLiteResultValueTypes::Integer)
            return FString::Printf(TEXT("%i"), IntValue);
        else if (Type == SQLiteResultValueTypes::Float)
            return FString::Printf(TEXT("%f"), DoubleValue);

        return StringValue;
    }
};

// Represents a single row in the result.
struct SQLiteResultValue
{
    TArray<SQLiteResultField> Fields;
};

// The internal result object.
struct SQLiteQueryResult
{
    bool Success;
    FString ErrorMessage;
    TArray<SQLiteResultValue> Results;
};



/**
* SQLite main database class.
*/
UCLASS()
class CISQLITE3_API USQLiteDatabase : public UObject
{
    GENERATED_UCLASS_BODY()

public:
    /** Create a sqlite database file if it doesn't exist already. Does nothing if already exists.
    *   Returns false if the file couldn't be created */
    UFUNCTION(BlueprintCallable, Category = "SQLite")
        static bool CreateDatabase(const FString& Filename, bool RelativeToGameContentDirectory);

    /** Checks if the database is registered, ie. that it can be found in Databases. */

    /** Add a database to the list of databases. It will be checked that it's valid (will try to open it) */
    UFUNCTION(BlueprintCallable, Category = "SQLite")
        static bool RegisterDatabase(const FString& Name, const FString& Filename, bool RelativeToGameContentDirectory, bool KeepOpen=false);

    /** Remove a database from the list of databases. Closes the database in case KeepOpen flag was set during @ref RegisterDatabase */
    UFUNCTION(BlueprintCallable, Category = "SQLite")
        static void UnregisterDatabase(const FString& Name);

    /** Checks if the database is registered, ie. that it can be found in Databases. */
    UFUNCTION(BlueprintCallable, Category = "SQLite")
        static bool IsDatabaseRegistered(const FString& DatabaseName);

    /** Get data from the database using a select statement straight into an UObject, ie. populates its properties. */
    UFUNCTION(BlueprintCallable, Category = "SQLite", meta = (DisplayName = "Get Data Into Object (manual query)"))
        static bool GetDataIntoObject(const FString& DatabaseName, const FString& Query, UObject* ObjectToPopulate);

    /** Blueprint: Gets data from the database using a select statement straight into an UObject, ie. populates its properties.
    *   Note: Does not create a new object. ObjectToPopulate is the reference to the object you want to populate. */
    UFUNCTION(BlueprintCallable, Category = "SQLite", meta = (DisplayName = "Get Data Into Object"))
        static bool GetDataIntoObjectBP(const FSQLiteDatabaseReference& DataSource, TArray<FString> Fields, FSQLiteQueryFinalizedQuery Query, UObject* ObjectToPopulate);

    /** Get data from the database using a select statement and return the rows. */
    UFUNCTION(BlueprintCallable, Category = "SQLite", meta = (DisplayName = "Get Data From Table(s) (manual query)"))
        static FSQLiteQueryResult GetData(const FString& DatabaseName, const FString& Query);

    /** Blueprint: Get data from the database. Returns the resulting rows. */
    UFUNCTION(BlueprintCallable, Category = "SQLite", meta = (DisplayName = "Get Data From Table(s)"))
        static FSQLiteQueryResult GetDataBP(const FSQLiteDatabaseReference& DataSource, TArray<FString> Fields, FSQLiteQueryFinalizedQuery Query, int32 MaxResults = -1, int32 ResultOffset = 0);

    /** Create table in the database. */
    UFUNCTION(BlueprintCallable, Category = "SQLite|Query", meta = (DisplayName = "Create Table"))
        static FSQLiteTable CreateTable(const FString& DatabaseName, const FString& TableName,
        const TArray<FSQLiteTableField> Fields, const FSQLitePrimaryKey PK);

    /** Create indexes for table */
    UFUNCTION(BlueprintCallable, Category = "SQLite|Query", meta = (DisplayName = "Create Indexes"))
        static bool CreateIndexes(const FString& DatabaseName, const FString& TableName, const TArray<FSQLiteIndex> Indexes);

    /** Create index for table */
    UFUNCTION(BlueprintCallable, Category = "SQLite|Query", meta = (DisplayName = "Create Index"))
        static bool CreateIndex(const FString& DatabaseName, const FString& TableName, const FSQLiteIndex Index);

    /** Drop index*/
    UFUNCTION(BlueprintCallable, Category = "SQLite|Query", meta = (DisplayName = "Drop Index"))
        static bool DropIndex(const FString& DatabaseName, const FString& IndexName);

    /** Drop Table*/
    UFUNCTION(BlueprintCallable, Category = "SQLite|Query", meta = (DisplayName = "Drop Table"))
        static bool DropTable(const FString& DatabaseName, const FString& TableName);

    /** Truncate Table*/
    UFUNCTION(BlueprintCallable, Category = "SQLite|Query", meta = (DisplayName = "Truncate Table"))
        static bool TruncateTable(const FString& DatabaseName, const FString& TableName);

    /** Is table exists?*/
    UFUNCTION(BlueprintCallable, Category = "SQLite|Query", meta = (DisplayName = "Is table exists?"))
        static bool IsTableExists(const FString& DatabaseName, const FString& TableName);

    /** Insert rows into table */
    UFUNCTION(BlueprintCallable, Category = "SQLite|Query", meta = (DisplayName = "Insert Rows Into Table"))
        static void InsertRowsIntoTable(const FString& DatabaseName, const FString& TableName, TArray<FSQLiteTableRowSimulator> rowsOfFields);

    /** Compact database*/
    UFUNCTION(BlueprintCallable, Category = "SQLite|Query", meta = (DisplayName = "Compact database"))
        static bool Vacuum(const FString& DatabaseName);

    /** Execute SQL (can be used for insert statement)*/
    UFUNCTION(BlueprintCallable, Category = "SQLite|Query", meta = (DisplayName = "Execute SQL"))
        static bool ExecSql(const FString& DatabaseName, const FString& Query);

    /** Checks database validity (if the file exists and/or if it can be opened). */
    UFUNCTION(BlueprintCallable, Category = "SQLite|Query", meta = (DisplayName = "Is Valid Database"))
        static bool IsValidDatabase(const FString& DatabaseFilename, bool TestByOpening);

    /** Runs a query and returns fetched rows. */
        static TUniquePtr<SQLiteQueryResult> RunQueryAndGetResults(const FString& DatabaseName, const FString& Query);
private:
    /** Tries to open a database. */
    static bool CanOpenDatabase(const FString& DatabaseFilename);
    /** Collects all properties from an UObject and maps them by the property name. */
    static TMap<FString, UProperty*> CollectProperties(UObject* SourceObject);
    /** Constructs an SQL query from the blueprint fed data. */
    static FString ConstructQuery(TArray<FString> Tables, TArray<FString> Fields, FSQLiteQueryFinalizedQuery QueryObject, int32 MaxResults = -1, int32 ResultOffset = 0);
    /** Assigns a result row's fields' values to an UObject, ie. assigns them to the properties that have the same name. */
    static void AssignResultsToObjectProperties(const SQLiteResultValue& ResultValue, UObject* ObjectToPopulate);
    /** @brief Prepare given statement, returns whether to keep the database open */
    static bool PrepareStatement(const FString& DatabaseName, const FString& Query, sqlite3** Db, int32** SqlReturnCode,
        sqlite3_stmt** PreparedStatement);


private:
    /** A list of the databases for convenience, easier to refer to them by name rather than a long filename. */
    static TMap<FString, FString> Databases;

    static TMap<FString, sqlite3*> SQLite3Databases;

};

用于 SQLiteDatabase.generated.h 的 PasteBin 因为太长而无法包含在问题正文中:

https://pastebin.com/ZFsg9KEv

此时我真的没有想法,我无法在网上找到任何与此插件类似的东西。不确定是否有人将它与更新版本的引擎一起使用。我本人和我电脑旁边的墙将非常感谢任何帮助。

【问题讨论】:

    标签: c++ plugins sqlite compiler-errors unreal-engine4


    【解决方案1】:

    所以,我已经设法通过直接使用合并到新项目的源文件夹中来解决这个问题,但我认为如果能够解决这个问题,UE4 社区将作为一个整体受益。虽然有一些用于 SQLite3 集成的不错的插件,但它们的成本很高,而且如果您不需要花里胡哨的功能,它们也不划算。

    【讨论】:

      猜你喜欢
      • 2021-09-09
      • 2020-11-18
      • 2015-09-24
      • 2018-02-18
      • 2020-05-18
      • 2022-06-19
      • 2021-07-26
      • 2021-06-21
      • 1970-01-01
      相关资源
      最近更新 更多