UE4和Azure存储SDK

问题描述 投票:1回答:1

我正在尝试将Azure存储sdk C ++库与Unreal Engine 4结合使用,以将图像上传到Azure云。库是使用vcpkg构建的,并且dll是动态链接的。这是我使用的代码的简化示例。

THIRD_PARTY_INCLUDES_START
#pragma warning(disable:4668) 
#pragma warning(disable:4005)   // 'TEXT': macro redefinition
#include <was/storage_account.h>
#include <was/blob.h>
#include <cpprest/filestream.h>  
#include <cpprest/containerstream.h> 
THIRD_PARTY_INCLUDES_END

const utility::string_t storage_connection_string(U("DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=MyAccountKey;EndpointSuffix=core.windows.net"));

void AAwsTest2GameModeBase::StartPlay() {
    try
    {
        // Retrieve storage account from connection string.
        azure::storage::cloud_storage_account storage_account = azure::storage::cloud_storage_account::parse(storage_connection_string);

        // Create the blob client.
        azure::storage::cloud_blob_client blob_client = storage_account.create_cloud_blob_client();

        // Retrieve a reference to a container.
        azure::storage::cloud_blob_container container = blob_client.get_container_reference(U("image-container"));

        azure::storage::cloud_block_blob blockBlob = container.get_block_blob_reference(U("28bbcdb0b3e5417b207572e292ae98412cd9d931eae6266f7c4fd788ad8544a20.jpg"));

        concurrency::streams::istream input_stream = concurrency::streams::file_stream<uint8_t>::open_istream(U("image.jpg")).get();
        blockBlob.upload_from_stream(input_stream);
        input_stream.close().wait();
    }
    catch (const std::exception& e)
    {
        std::wcout << U("Error: ") << e.what() << std::endl;
    }
}

Build.cs内容

public class Program : ModuleRules
{
    public Program(ReadOnlyTargetRules Target) : base(Target)
    {
        PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;

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

        //I tried to use ansi allocator but it did not help
        //PublicDefinitions.Add("FORCE_ANSI_ALLOCATOR");

        PublicIncludePaths.Add(Path.Combine(DependencyFolderWin, "include"));
        PublicAdditionalLibraries.Add(Path.Combine(DependencyFolderWin, "lib", "wastorage.lib"));
        PublicAdditionalLibraries.Add(Path.Combine(DependencyFolderWin, "lib", "cpprest_2_10.lib"));
        PublicAdditionalLibraries.Add(Path.Combine(DependencyFolderWin, "lib", "brotlicommon.lib"));
        PublicAdditionalLibraries.Add(Path.Combine(DependencyFolderWin, "lib", "brotlidec.lib"));
        PublicAdditionalLibraries.Add(Path.Combine(DependencyFolderWin, "lib", "brotlienc.lib"));
        PublicAdditionalLibraries.Add(Path.Combine(DependencyFolderWin, "lib", "zlib.lib"));

    }

    private string DependencyFolderWin
    {
        get
        {
            string moduleDir = Path.GetFullPath(ModuleDirectory);
            return Path.Combine(moduleDir, "./../../deps");
        }
    }
}

问题是它成功地上传了图像,并在此函数从此函数返回后立即崩溃(在本例中为StartPlay()或在调用栈中为Upload())。

UE4Editor-Core.dll!00007ff9e620ff1b()   Unknown
UE4Editor-Core.dll!00007ff9e62109e3()   Unknown
UE4Editor-Core.dll!00007ff9e6211592()   Unknown
UE4Editor-Core.dll!00007ff9e5e95277()   Unknown
[Inline Frame] UE4Editor-MsgQueuePlugin.dll!operator delete(void *) Line 31 C++
[Inline Frame] UE4Editor-MsgQueuePlugin.dll!std::_Deallocate(void * _Ptr, unsigned __int64 _Bytes) Line 207 C++
[Inline Frame] UE4Editor-MsgQueuePlugin.dll!std::allocator<wchar_t>::deallocate(wchar_t * const) Line 992   C++
UE4Editor-MsgQueuePlugin.dll!std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> >::_Tidy_deallocate() Line 3992    C++
[Inline Frame] UE4Editor-MsgQueuePlugin.dll!std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> >::{dtor}() Line 2460   C++
UE4Editor-MsgQueuePlugin.dll!web::uri::~uri()   C++
UE4Editor-MsgQueuePlugin.dll!azure::storage::cloud_blob::~cloud_blob()  C++
UE4Editor-MsgQueuePlugin.dll!AzureUploader::Upload(TArray<unsigned char,FDefaultAllocator> file, const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & path, const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & fileName) Line 37  C++

带有编辑器调试符号的Callstack:

[Inline Frame] UE4Editor-Core.dll!__TBB_machine_cmpswp1(volatile void *) Line 69    C++
[Inline Frame] UE4Editor-Core.dll!__TBB_TryLockByte(unsigned char &) Line 917   C++
UE4Editor-Core.dll!__TBB_LockByte(unsigned char & flag) Line 924    C++
[Inline Frame] UE4Editor-Core.dll!MallocMutex::scoped_lock::{ctor}(MallocMutex &) Line 66   C++
UE4Editor-Core.dll!rml::internal::Block::freePublicObject(rml::internal::FreeObject * objectToFree) Line 1382   C++
[Inline Frame] UE4Editor-Core.dll!rml::internal::internalPoolFree(rml::internal::MemoryPool * memPool, void *) Line 2571    C++
UE4Editor-Core.dll!rml::internal::internalFree(void * object) Line 2595 C++
UE4Editor-Core.dll!FMemory::Free(void * Original) Line 76   C++
[External Code] 
UE4Editor-MsgQueuePlugin.dll!AzureUploader::Upload(TArray<unsigned char,FDefaultAllocator> file, const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & path, const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & fileName) Line 37  C++

看起来像是从某些结构中删除uri时崩溃了。问题可能出在虚幻的内存管理上。我尝试使用ansi分配器,但没有帮助。任何想法如何使其正常工作?谢谢

我正在尝试将Azure存储sdk C ++库与Unreal Engine 4结合使用,以将图像上传到Azure云。库是使用vcpkg构建的,并且dll是动态链接的。这是...

c++ memory-management unreal-engine4 azure-sdk
1个回答
0
投票

[最后,使用this example中的UE4插件解决了。这不是我想要的解决方案,但至少可以奏效。有静态链接的库和硬编码的编译器版本,将来可能会出现问题。

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.