x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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: https://wiki.unrealengine.com/Linking_Static_Libraries_Using_The_Build_System. 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");
 
              PublicLibraryPaths.Add(LibrariesPath);
 
              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));
      }
  }


Product Version: Not Selected
Tags:
more ▼

asked Mar 26 '15 at 03:50 PM in C++ Programming

avatar image

ProfessionsQuest
193 16 21 22

avatar image bigzer Jun 14 '15 at 10:00 AM

Hello ProfessionsQuest,

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

avatar image Tống Tùng Giang Oct 11 '16 at 01:23 PM

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

avatar image Louspirit Jan 19 '18 at 04:16 PM

Hello,

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)

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question