YetiTech-Studios / UE4GameLiftClientSDK

Gamelift Client SDK for Unreal Engine 4.
MIT License
79 stars 41 forks source link

Failed to load aws-cpp-sdk-cognito-identity, core and gamelift #19

Open richterk opened 4 years ago

richterk commented 4 years ago

So, I built the aws-cpp-sdk and replaced the DLLs and libs for the three dependencies, and changed the version number in the Build.cs. When I try to launch the game, none of the DLLs are able to load. The Plugin still shows up in the editor, but when I try to launch the game, those errors popup again and stop the game from connecting to AWS gamelift.

Any help is appreciated.

@chris-gong, any ideas?

chris-gong commented 4 years ago

Hi Kirk, the sdk was recently updated so I'm going to look into this issue further.

chris-gong commented 4 years ago

I have confirmed that since I have updated the aws cpp sdk dll and lib files to version 1.7.x, the aws core sdk relies on some dependencies. And as a result, if core can't load, then neither can cognito-identity nor gamelift. These dependencies include aws-c-common, aws-c-event-stream, and aws-checksums, so I have to not only add these dll and lib files but also modify AWSCore.Build.cs to account for these dependencies.

Jeff-Stapleton commented 4 years ago

I am experiencing the same issue. Has there been any progress made?

DanielSanchez97 commented 4 years ago

I had the same problem as above and was able to fix it. Since Chris said it happened when he updated the aws sdk, I looked and saw he updated the .dlls in the most recent commit, so I checked out the last commit (22bd73257e3a107e2ccadcaa8235ada255ff7aed) and then grabbed the .dlls and .libs from there. I then dropped those into the most recent version of the plugin and the error messages didn't pop up. I have not tested any functionality cause I just got it working, but i figured I would let you know my work around. @Jeff-Stapleton @richterk

DarkXoro commented 4 years ago

The same issue occurs to me too. Any help would be appreciated. Also here is the error output

LogWindows: Failed to preload '<project directory>/Plugins/GameLiftClientSDK/Binaries/Win64/aws-cpp-sdk-core.dll' (GetLastError=126)
LogWindows:   Missing import: USERENV.dll
LogWindows:   Missing import: WININET.dll
LogWindows:   Missing import: aws-c-event-stream.dll
LogWindows:   Missing import: aws-c-common.dll
DevGarou commented 4 years ago

I am having the same issue too, I even tried to add this to the build.cs files of the modules: PublicDefinitions.Add("USE_WINDOWS_DLL_SEMANTICS"); PublicDefinitions.Add("USE_IMPORT_EXPORT");

chris-gong commented 4 years ago

If possible, I would say try to look at my fork. I know it's a little rough right now. I do plan on updating it sometime soon, but essentially the issue is that since I updated the aws sdk used in this client sdk, I have to also update the dll/lib files, which now include some new dependencies.

stormouse commented 4 years ago

^ using Chris' fork solved my problem

DevGarou commented 4 years ago

I added the new dependencies, which are aws-c-common, aws-c-event-stream and aws-checksums and it seems to work now

Le 15 avr. 2020 à 09:24, Shawnc notifications@github.com a écrit :

^ using Chris' fork solved my problem

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

JakeDCW commented 9 months ago

To fix this in Unreal 5.0+, and in other related AWS items with dll, add to your Build.cs file for the module (ie. AWSSDK) this code.

Example problem:

[2023.09.26-10.49.23:158][  0]LogWindows:   Missing import: WININET.dll
[2023.09.26-10.49.23:158][  0]LogWindows:   Missing import: zlib1.dll

Fix:

        string LibraryPath = Path.Combine(ModuleDirectory, "Binaries", Target.Platform.ToString());
        //zlib fix
        if (Target.Platform == UnrealTargetPlatform.Win64)
        {
            PublicAdditionalLibraries.Add(Path.Combine(LibraryPath, "zlib.lib"));
            // Stage the library along with the target, so it can be loaded at runtime.
            RuntimeDependencies.Add("$(BinaryOutputDir)/" + "zlib1.dll", Path.Combine(LibraryPath, "zlib1.dll"));
        }

This will load the dlls and libs from the folder. zlib contains the wininet.dll :)

This is derived from the Game Analytics build.cs tutorial and files.

JakeDCW commented 9 months ago

Full AWSSDK module build.cs file I am using, working as of 5.2.1 on 26/09/23

using System;
using System.Collections.Generic;
using System.IO;
using UnrealBuildTool;

public class AWSSDK : ModuleRules
{
    // list every library you plan to use here
    private List<string> LibraryNames = new List<string>()
    {
        "aws-c-auth",
        "aws-c-cal",
        "aws-c-common",
        "aws-c-compression",
        "aws-c-event-stream",
        "aws-checksums",
        "aws-c-http",
        "aws-c-io",
        "aws-c-mqtt",
        "aws-cpp-sdk-access-management",
        "aws-cpp-sdk-cognito-identity",
        "aws-cpp-sdk-core",
        "aws-cpp-sdk-iam",
        "aws-cpp-sdk-kinesis",
        "aws-crt-cpp",
        "aws-c-s3",
        "aws-c-sdkutils"
    };

    public AWSSDK(ReadOnlyTargetRules Target) : base(Target)
    {
        // ModuleType.External tells the engine not to look for (or compile) any source code.
        Type = ModuleType.External;
        PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;

        // add the header files for reference
        PublicIncludePaths.Add(Path.Combine(ModuleDirectory, "Include"));

        // AWS SDK relies on certain identifiers being undefined, so this produces warnings
        // Unreal engine treats certain warnings as errors and fails the build
        // this line will disable those warnings:
        bEnableUndefinedIdentifierWarnings = false;

        // Dynamically linking to the SDK requires us to define the
        // USE_IMPORT_EXPORT symbol for all build targets using the
        // SDK. Source: https://github.com/aws/aws-sdk-cpp/blob/main/Docs/SDK_usage_guide.md#build-defines
        PublicDefinitions.Add("USE_IMPORT_EXPORT");
        PublicDefinitions.Add("AWS_CRT_CPP_USE_IMPORT_EXPORT");

        if (Target.Platform == UnrealTargetPlatform.Win64)
        {
            PublicDefinitions.Add("USE_WINDOWS_DLL_SEMANTICS");
        }

        string LibraryPath = Path.Combine(ModuleDirectory, "Binaries", Target.Platform.ToString());
        // do this for each lib and dll
        foreach (string libName in LibraryNames)
        {

            // add a new section for each platform you plan to compile for (only Win64 is included for this example)
            if (Target.Platform == UnrealTargetPlatform.Win64)
            {
                PublicAdditionalLibraries.Add(Path.Combine(LibraryPath, libName + ".lib"));
                // Stage the library along with the target, so it can be loaded at runtime.
                RuntimeDependencies.Add("$(BinaryOutputDir)/" + libName + ".dll", Path.Combine(LibraryPath, libName + ".dll"));
            }
            else if (Target.Platform == UnrealTargetPlatform.Mac)
            {
                // add mac libraries
            }
            else if (Target.Platform == UnrealTargetPlatform.Linux)
            {
                // add linux libraries
            }
        }

        //zlib fix
        if (Target.Platform == UnrealTargetPlatform.Win64)
        {
            PublicAdditionalLibraries.Add(Path.Combine(LibraryPath, "zlib.lib"));
            // Stage the library along with the target, so it can be loaded at runtime.
            RuntimeDependencies.Add("$(BinaryOutputDir)/" + "zlib1.dll", Path.Combine(LibraryPath, "zlib1.dll"));
        }

        PrivateDependencyModuleNames.AddRange(
        new string[] {
                    "CoreUObject",
                    "Engine",
                    "Slate",
                    "SlateCore",
        });
    }
}