【发布时间】:2015-09-11 09:56:18
【问题描述】:
我正在尝试将静态第三方库链接到 Unreal Engine 4。
我正在尝试包含一个名为 libZPlay 的第三方库/SDK。我尝试按照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 文件夹中有一个 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 位版本),而虚幻引擎 4 只能编译 64 位。任何见解都会很棒!
【问题讨论】:
标签: c++ visual-studio-2013 static-linking unresolved-external unreal-engine4