LuaJit LNK error when integrating into UE4

I’m getting this error “luajit.lib(luajit.exe) : error LNK2005: _vsnprintf already defined in 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 Re_BricksAlpha : ModuleRules
{
    private string ThirdPartyPath
    {
        get { return Path.GetFullPath(Path.Combine(ModuleDirectory, "../../ThirdParty/")); }
    }
    public Re_BricksAlpha(ReadOnlyTargetRules Target) : base(Target)
    {
        PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;

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

        PrivateDependencyModuleNames.AddRange(new string[] {  });

        // 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
        bool isLibSupported = true;

        string LibrariesPath = Path.Combine(ThirdPartyPath, "LuaJit", "libraries");

        PublicAdditionalLibraries.Add(Path.Combine(LibrariesPath, "luajit.lib"));

        PublicIncludePaths.Add(Path.Combine(ThirdPartyPath, "LuaJit", "includes"));

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

is this CryptPP doing this? I wish to uninstall any libraries which are conflicting with LuaJit if that’s the case,

I found out I can use /FORCE:MULTIPLE to fix my issue, however, I cannot seem to find Linker Options in UE4 nor VS2017?

I tried UE 4.20 Preview 2 as-well and I got this error when packaging for shipping,

luajit.lib(luajit.exe) : error LNK2005: _vsnprintf already defined in libeay.lib(cryptlib.obj)

It crashes on launch too. Both (UE 4.19.2 and 4.20 Preview 2) compile fine but launching and packaging gives those errors.

I also created a thread on the forums but it has been there for 6 days with absolutely no answers.

Any help would be appreciated, thanks :wink:

I know this is a pretty old question, but since I haven’t seen an appropriate answer anywhere else and spent far too long figuring this out, I figured I’d help out any poor soul that is running into the same issue.

The basic, afaik unavoidable problem is that the msvcbuild version of LuaJIT has extra symbols in it for (apparently) no reason. Here are the steps I took to compile a working version:

  • Download the LuaJIT Windows source
    -Open the Makefile and
    • Set the mode to dynamic
    • OPTIONALLY enable the DLUAJIT_ENABLE_LUA52COMPAT flag
  • Compile using mingw32-make (mingw-w64)
  • Copy the lua51.dll file to another folder.
  • Using the x64 Native Tools Comand Prompt for VS 2017, export the external symbols found in the DLL
    dumpbin /EXPORTS lua51.dll > lua51.exports
  • From the exports file, create a separate .def file pointing to the dll containing all the symbol references
  • Using the x64 Native Tools Comand Prompt for VS 2017, generate the lib and exp files based on the def file
    lib /def:lua51.def /out:lua51.lib

You now have a DLL and a LIB that links to it!

  • You may now copy the dll, lib and exp file to the location you want to install Lua to.
  • Finish following the Installation instructions on the LuaJIT website, for my own paths, that was
    • Copy all files from K:/Git Repos/luajit205-52-libdll/luajit205-52-dll/src to C:/LUA
    • Copy the files from K:/Git Repos/luajit205-52-libdll/luajit205-52-dll/src/jit to C:/LUA/lua/jit

I wrote out the full procedure and how I worked through it, along with the dll/lib/exp I use to one of my git repos, so for extra doc and potentially useful files, head here:

,

I know this is a pretty old question, but since I haven’t seen an appropriate answer anywhere else and spent far too long figuring this out, I figured I’d help out any poor soul that is running into the same issue.

The basic, afaik unavoidable problem is that the msvcbuild version of LuaJIT has extra symbols in it for (apparently) no reason. Here are the steps I took to compile a working version:

  • Download the LuaJIT Windows source
    -Open the Makefile and
    • Set the mode to dynamic
    • OPTIONALLY enable the DLUAJIT_ENABLE_LUA52COMPAT flag
  • Compile using mingw32-make (mingw-w64)
  • Copy the lua51.dll file to another folder.
  • Using the x64 Native Tools Comand Prompt for VS 2017, export the external symbols found in the DLL
    dumpbin /EXPORTS lua51.dll > lua51.exports
  • From the exports file, create a separate .def file pointing to the dll containing all the symbol references
  • Using the x64 Native Tools Comand Prompt for VS 2017, generate the lib and exp files based on the def file
    lib /def:lua51.def /out:lua51.lib

You now have a DLL and a LIB that links to it!

  • You may now copy the dll, lib and exp file to the location you want to install Lua to.
  • Finish following the Installation instructions on the LuaJIT website, for my own paths, that was
    • Copy all files from K:/Git Repos/luajit205-52-libdll/luajit205-52-dll/src to C:/LUA
    • Copy the files from K:/Git Repos/luajit205-52-libdll/luajit205-52-dll/src/jit to C:/LUA/lua/jit

I wrote out the full procedure and how I worked through it, along with the dll/lib/exp I use to one of my git repos, so for extra doc and potentially useful files, head here:

Sorry for the long delay in a reply… Long ago I just recompiled the third party libraries that UE4 used that were having errors with it. I just used UltraSearch to find anything that contained cryptlib. I think Epic might have modified these because for some reason recompiling all the libraries that referenced cryptlib in the LNK error let projects integrated with LuaJit successfully compile when exporting with no hitches.

This is a much better method though, thanks <3 ^-^

1 Like