LNK 2019 Error when importing third party lib (Mini UPnP)

I’m trying to allow users to host their own multiplayer games without changing the port forwarding on their router. Thanks to this AnswerHub thread, I’m trying MiniUPnP. In order to add this to my project, I compiled the MiniUPnP project using this tutorial: A new, community-hosted Unreal Engine Wiki - Announcements - Unreal Engine Forums. I made sure to set the project to export as a .lib and as a multi-threaded DLL. I created two lib files, miniupnpc.x64.lib and miniupnpc.x86.lib (just in case). They’re different sizes so clearly the project understands the x64 configuration.

Next, I moved to Unreal, creating the ThirdParty folder as described in the tutorial (including Libraries and Includes folders). I’ve added MiniUPnP to PublicDependencyModuleNames and created MiniUPnP.Build.cs. I believe I’ve done all of this correctly because if I remove any of these steps, Unreal gives me a compile-time error on #include “miniupnpc.h”. As it is, it reads the includes perfectly but gives me Error LNK2019: unresolved external symbol on each method I call from the MiniUPnP library. I assume this is because something is wrong with the .lib file so it’s having trouble reading it but I wouldn’t know what. I’ve double checked every step in the tutorial and every AnswerHub question I could find but no dice. Anyone know what I’m missing? Or any other libraries that have a similar function?

Here’s my MiniUPnP.Build.cs file if anyone needs it:

public class MiniUPnP : ModuleRules 
    public MiniUPnP(TargetInfo Target) 
		Type = ModuleType.External;

        bool isLibrarySupported = false;

        string ThirdPartyPath = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(RulesCompiler.GetModuleFilename(this.GetType().Name)), "../../ThirdParty"));

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

             string PlatformString = (Target.Platform == UnrealTargetPlatform.Win64) ? ".x64" : ".x86";
             string LibrariesPath = Path.Combine(ThirdPartyPath, "MiniUPnP", "Libraries");


             PublicAdditionalLibraries.Add(Path.Combine(LibrariesPath, "miniupnpc" + PlatformString + ".lib"));

         if (isLibrarySupported)
             // Include path
             PublicIncludePaths.Add(Path.Combine(ThirdPartyPath, "MiniUPnP", "Includes"));
             PublicSystemIncludePaths.Add(Path.Combine(ThirdPartyPath, "MiniUPnP", "Includes"));

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

Hello ProfessionsQuest,

Have you found a solution to this problem?
I’m also hoping to add UPNP port forwarding to our multiplayer game.

I’m finding the solution for the same problem too.


Have you found the solution to this problem?
I have the same error.

I have tried to add the following on right click on project > VC++ > General

  • Include rep : ..\..\ThirdParty\MiniUPnP\include

  • Library rep : ..\..\ThirdParty\MiniUPnP\lib

without success…
UpnpLibrary.cpp.obj : error LNK2019: symbole externe non rÚsolu __imp_upnpDiscover rÚfÚrencÚ dans la fonction "public: static void __cdecl UUpnpLibrary::getRouter(void)" (?getRouter@UUpnpLibrary@@SAXXZ)