[英]LNK2005 error when integrating LuaJit in UE4 (Unreal Engine 4)
lua51.lib(lua51.dll):错误LNK2005:_vsnprintf已在libcurl_a.lib(cryptlib.obj)中定义
GameName.Build.cs->
// Fill out your copyright notice in the Description page of Project Settings.
using System.IO;
using UnrealBuildTool;
public class GameName : ModuleRules
{
private string ThirdPartyPath
{
get { return Path.GetFullPath(Path.Combine(ModuleDirectory, "../../ThirdParty/")); }
}
private bool LoadLua()
{
bool isLibSupported = false;
string LibrariesPath = Path.Combine(ThirdPartyPath, "Lua", "libraries");
PublicAdditionalLibraries.Add(Path.Combine(LibrariesPath, "lua51.lib"));
PublicIncludePaths.Add(Path.Combine(ThirdPartyPath, "Lua", "includes"));
Definitions.Add(string.Format("WITH_LUA_BINDING={0}", isLibSupported ? 1 : 0));
return true;
}
public GameName(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" });
PrivateDependencyModuleNames.AddRange(new string[] { });
LoadLua();
// Uncomment if you are using Slate UI
// PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });
// Uncomment if you are using online features
// PrivateDependencyModuleNames.Add("OnlineSubsystem");
// To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true
}
}
ActorName.cpp->
// Fill out your copyright notice in the Description page of Project Settings.
#include "ActorName.h"
extern "C" {
#include "lua.h"
#include "lualib.h"
#include "lauxlib.h"
#include "luaconf.h"
#pragma comment(lib, "lua51.lib")
}
// Sets default values
APart::APart()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
}
// Called when the game starts or when spawned
void APart::BeginPlay()
{
Super::BeginPlay();
lua_State *L = luaL_newstate();
luaL_openlibs(L);
FVector NewLocation = GetActorLocation();
NewLocation.Z = NewLocation.Z + 200.0f;
}
// Called every frame
void APart::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
/*FVector NewLocation = GetActorLocation();
float DeltaHeight = (FMath::Sin(RunningTime + DeltaTime) - FMath::Sin(RunningTime));
NewLocation.Z += DeltaHeight * 100.0f;
NewLocation.Y += DeltaHeight * 800.0f;//Scale our height by a factor of 20
RunningTime += DeltaTime;
SetActorLocation(NewLocation);*/
}
我为64x编译了LuaJit,但我不包括32x构建,我需要吗? 我不打算在32位系统上发布我的游戏,因为没有意义(大笑)(除了IOS,因为我很确定您必须上传该应用的32位和64位版本:3)
我只包含Lua51.lib一次吗? 我做错什么了吗?
我知道这是一个很老的问题,但是由于我在其他任何地方都没有找到合适的答案,并且花了太长时间才弄清楚这个问题,所以我认为我会帮助遇到这个问题的可怜人。
afaik不可避免的基本问题是LuaJIT的msvcbuild版本出于(显然)没有理由而在其中包含了额外的符号。 这是我编译工作版本所采取的步骤:
dumpbin /EXPORTS lua51.dll > lua51.exports
找到的外部符号 lib /def:lua51.def /out:lua51.lib
生成lib和exp文件 您现在有了一个DLL和一个链接到它的LIB!
我写出了完整的过程以及如何使用它,以及我在其中一个git仓库中使用的dll / lib / exp,所以对于其他文档和可能有用的文件,请转到此处:
https://github.com/Zaltu/luajit205-52-libdll
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.