0

I have a executable project, Game.exe, which is linking against a library Engine.lib. I want to link another internal library, Video.lib, into Engine.lib, so that Game.exe can simply link against Engine.lib and not worry about the symbols provided by Video.lib. This sort of linking setup makes the most sense for my current solution.

In the librarian tab of Engine.lib, I have included the path of Video.lib as well as the file "Video.lib" in the input section. This works perfectly and I have access to the Video.lib symbols.

My issue is when trying to link against Engine.lib from Game.exe. I am not sure if I changed some sort of setting in the Game.exe project, but when I try build Game.exe, I get a linking error that Video.lib cannot be found. How is this possible, when I do not have "Video.lib" under the inputs of Game.exe?

Adding the path of the Video.lib file (simply the path, not the file itself) to the Game.exe project solves this, but obviously the whole point of this setup is that Video.lib should be merged into Engine.lib so that I only have to link Game.exe against Engine.lib.

Is there a setting in Engine.lib I have to set that specifies all Video.lib symbols should be pulled into Engine.lib, instead of making it a dependency for future projects that link against Engine.lib? Or have I set something incorrectly in the Game.exe project?

I do not want to use Visual Studio's "project dependencies" or "references" system.

Thanks!

Edit: This post here (Linking static libraries to other static libraries) does not answer my question, as it is both outdated (doesn't really contain information about the new VS interface) and doesn't answer the issue I am having (why is Game.exe trying to link against Video.lib). Since my question is about this problem and the other question is simply a "how to" I therefore do not believe my question is a duplicate.

Edit 2: I am certain that Video.lib IS being linked into Engine.lib due to the noticeable increase in file size. What I don't understand is why Game.exe still complains about not being able to find Video.lib

Gary Allen
  • 1,218
  • 1
  • 13
  • 28
  • This is 100% duplicate, note that solution for joining libs in VS is posted there as second answer by John Knoeller. Even though it is pretty old it should still work just fine. Linker tools are quite conservative. – user7860670 Nov 05 '20 at 11:16
  • The thread suggests that ticking "Link Library Dependencies" does this for you, but I have issues when using this. I am asking for help, since that solution isn't working for me – Gary Allen Nov 05 '20 at 11:24
  • Have you checked that Engine.lib contains Video.lib stuff? If it does then Game.exe is not supposed to link Video.lib at all. – user7860670 Nov 05 '20 at 11:28
  • Yes, it does. I have setup an incredibly simple solution to test all of this, and still get the same issues i.e. I must be doing something wrong. Engine.lib contains a single function which in turn calls a Video.lib function. See my second edit for more details on my problem @user7860670 – Gary Allen Nov 05 '20 at 11:29
  • Well, i don't know. Maybe this is some sort of trivial typo: for example Game.exe still links Video.lib because you've edited property page for wrong Platform / Configuration. – user7860670 Nov 05 '20 at 11:35
  • Nope. I've created a blank project so am 100% sure Game.exe does not try directly link against Video.lib – Gary Allen Nov 05 '20 at 12:00

1 Answers1

0

The issue turned out to be with the library I was using specifically, which is wxWidgets (I simplified the example above in order to avoid complications).

wxWidgets uses #pragma comments to link specific libraries in. In this case, wxWidgets ("Video.lib") was causing Game.exe to "see" these pragma comments and ultimately attempt to link in the libraries.

Adding all the wxWidgets libraries ("Video.lib") to "Ignore Specific Default Libraries" under Linker -> Input in Game.exe solved the problem to me, as this ultimately overrode the pragma directives.

Gary Allen
  • 1,218
  • 1
  • 13
  • 28