gpt4 book ai didi

c++ - 虚幻引擎 4 链接静态第 3 方库/SDK (libZPlay)

转载 作者:太空宇宙 更新时间:2023-11-04 13:32:01 25 4
gpt4 key购买 nike

我正在尝试将静态第三方库链接到虚幻引擎 4。

我正在尝试包含一个名为 libZPlay 的第三方库/SDK .我尝试关注 Linking Static Libraries Using The Build System然而,维基指南遇到了问题。我正在使用 UE 4.8.0,libZPlay 是一个 32 位库。

以下是我按照指南后的当前构建文件:

using UnrealBuildTool;
using System.IO;

public class Rhythm : ModuleRules{
//for linking 3rd party libraries
private string ModulePath{
get { return Path.GetDirectoryName(RulesCompiler.GetModuleFilename(this.GetType().Name)); }
}
private string ThirdPartyPath{
get { return Path.GetFullPath(Path.Combine(ModulePath, "../../ThirdParty/")); }
}
//normal after this
public Rhythm(TargetInfo Target){
MinFilesUsingPrecompiledHeaderOverride = 1;//faster builds
bFasterWithoutUnity = true;//faster builds
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" });
PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });//for UMG

LoadlibZPlay(Target); //load libZPlay library
}

public bool LoadlibZPlay(TargetInfo Target){
bool isLibrarySupported = false;

if ((Target.Platform == UnrealTargetPlatform.Win64) || (Target.Platform == UnrealTargetPlatform.Win32)){
isLibrarySupported = true;

string PlatformString = (Target.Platform == UnrealTargetPlatform.Win64) ? "x64" : "x86"; //prob not needed since only one version of the file
string LibrariesPath = Path.Combine(ThirdPartyPath, "libZPlay", "Libraries");

PublicAdditionalLibraries.Add(Path.Combine(LibrariesPath, "libzplay.lib"));
//PublicAdditionalLibraries.Add(Path.Combine(LibrariesPath, "libzplay_borland.lib"));
PublicAdditionalLibraries.Add(Path.Combine(LibrariesPath, "libzplay.a"));
//PublicAdditionalLibraries.Add(Path.Combine(LibrariesPath, "libzplay.dll"));
PublicDelayLoadDLLs.Add(Path.Combine(LibrariesPath, "libzplay.dll"));
}

if (isLibrarySupported){
//include path
PublicIncludePaths.Add(Path.Combine(ThirdPartyPath, "libZPlay", "Includes"));
}

Definitions.Add(string.Format("WITH_LIBZPLAY_BINDING={0}", isLibrarySupported ? 1 : 0));

return isLibrarySupported;
}

我在项目的根目录中有一个 ThirdParty 文件夹,其中有一个 libZPlay 文件夹,其中包含一个包含我的头文件的文件夹。此外,在 libZPlay 文件夹中有一个 Libraries 文件夹,其中包含我的 libZPlay.dll、libZPlay.lib 和 libZPlay.a 文件。头文件以下列方式包含:#include "../../ThirdParty/libZPlay/Includes/libzplay.h"。添加所有这些后,visual studio 文件也重新生成。

我尝试从名为“CreateZPlay()”的外部库运行一个函数,如下所示:

void UMusicAnalyzerWidget::initilizeMusicAnalyzer(){
player = libZPlay::CreateZPlay();
filePath = "D:/Christian/Music/Archive/Stick Me In My Heart (Radio Edit).mp3";
}

'player' 是在 UMusicAnalyzerWidget 类中创建的 ZPlay 指针,该函数几乎可以创建和初始化对象。但是,在尝试构建/编译时出现以下错误:

Error   8   error LNK2019: unresolved external symbol __imp_CreateZPlay referenced in function "public: void __cdecl UMusicAnalyzerWidget::execinitilizeMusicAnalyzer(struct FFrame &,void * const)" (?execinitilizeMusicAnalyzer@UMusicAnalyzerWidget@@QEAAXAEAUFFrame@@QEAX@Z)    D:\GitHub\Rhythm\Rhythm\Intermediate\ProjectFiles\MusicAnalyzerWidget.cpp.obj   Rhythm
Error 9 error LNK1120: 1 unresolved externals D:\GitHub\Rhythm\Rhythm\Binaries\Win64\UE4Editor-Rhythm.dll 1 1 Rhythm
Error 10 error : Failed to produce item: D:\GitHub\Rhythm\Rhythm\Binaries\Win64\UE4Editor-Rhythm.dll D:\GitHub\Rhythm\Rhythm\Intermediate\ProjectFiles\ERROR Rhythm
Error 11 error MSB3075: The command ""D:\Programs\Epic Games\4.8\Engine\Build\BatchFiles\Rebuild.bat" RhythmEditor Win64 Development "D:\GitHub\Rhythm\Rhythm\Rhythm.uproject" -rocket" exited with code 5. Please verify that you have sufficient rights to run this command. C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.MakeFile.Targets 43 5 Rhythm

环顾四周之后,我陷入了困境,不确定如何继续。我相信这可能是因为这是一个 32 位库(没有任何 64 位版本),而 Unreal Engine 4 只能在 64 位编译。任何见解都会很棒!

最佳答案

您提供的链接实际上证实了您对 UE4 不支持 32 位库的怀疑:

With a standard Static Library project we will be targeting x86 (32 bit) machines, which wont work for the UE4 toolset.

您需要 64 位版本。

关于c++ - 虚幻引擎 4 链接静态第 3 方库/SDK (libZPlay),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31039406/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com