Mini UPnP Integration

Hello everybody, we are trying to integrate Mini UPnP into our project and have run into some issues.

We made an entry on the answer hub here:
But haven’t had much luck, so we thought to try seeing if any one on the forums had any experience or help.

I’m trying to allow users to host their own multiplayer games without changing the port forwarding on their router. Thanks to, 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 and Releases - 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));

Sorry for the bump, but does any one have an experience in incorporating a Third Party library, such as MiniUPnP or anything else?

Can you do <lib>.x64.lib? If someone is trying to get the extension somewhere, I’m not sure what it would return (.x64, .x64.lib, or .lib). Have you checked your game project properties and the lib you added is there (Right Click on your game solution -> Properties -> Linker -> Input -> Verify its listed in the “Additional Dependencies” field)? You verified the Build.cs code is executing as expected (isLibrarySupported is true, etc)?

I’m not sure how to check that isLibrarySupported is true, but it’s successfully using the include files. Also, neither the solution nor the project has a Linker category under properties, but under Configuration Properties->VC++ Directories, I have my MiniUPnP libraries folder under Library Directories.

It’s also worth noting that I’ve successfully incorporated other libraries but I’ve created from scratch, so I don’t think it’s the Build.cs file.

Just a tiny bump. We have definitely looked everywhere and still can’t get it working. :frowning:

You might be interested in this.