1

我想4.虛幻引擎4靜態鏈接第三方庫/ SDK(libZPlay)

我想包括第三方庫/ SDK稱爲libZPlay靜態第三方庫鏈接到虛幻引擎。我試圖遵循Linking Static Libraries Using The Build System wiki指南,但是,我遇到了問題。我正在使用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; 
} 

}

我在項目的根目錄中的第三方文件夾,一個libZPlay文件夾中有一個包含包含我的頭文件的文件夾。另外,在libZPlay文件夾中有一個包含我的libZPlay.dll,libZPlay.lib和libZPlay.a文件的Libraries文件夾。頭文件以下列方式包含:#include「../../ThirdParty/libZPlay/Includes/libzplay.h」。所有這些添加完成後,視覺工作室文件也被重新生成。

我嘗試運行的功能從上述所謂的「CreateZPlay()」,如下圖所示外部庫:

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

「球員」是UMusicAnalyzerWidget類中創建了一個ZPlay指針,功能非常創建和初始化對象。然而,試圖建立時/編譯我收到以下錯誤:

Error 8 error LNK2019: unresolved external symbol __imp_CreateZPlay referenced in function "public: void __cdecl UMusicAnalyzerWidget::execinitilizeMusicAnalyzer(struct FFrame &,void * const)" ([email protected]@@[email protected]@[email protected]) 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位版本),而虛幻引擎4僅在64位編譯。任何見解都會很棒!

回答

0

您所提供的鏈接實際上確認了你的懷疑,UE4不支持32位的庫:

隨着我們將針對86(32位)的機器,這不會工作的UE4工具箱的標準靜態庫項目。

您將需要一個64位版本。

+0

是的,我知道它不適用於32位二進制文​​件。我決定使用不同的庫。不過,我想知道如何從給定的內容創建64位二進制文​​件。 – ChrisTheEngineer

+0

找不到您爲庫提供的鏈接,但是,您只需要在64位配置中重新編譯它即可。 – MuertoExcobito