Search code examples
c++visual-studiosymbolsstatic-linking

.lib linking other .libs


Currently my visual studio is basically generating Engine.dll and Game.exe

Engine.dll links to some other basic libraries like: d3dx9d.lib ComCtl32.lib WinMM.lib WSock32.lib etc.

I also wanted to try to create an Engine.lib, but I get some really nice warnings now: Symbol x has been defined already. These libraries define the same symbols.

So I read somewhere that I must force my user (Game.exe) to link to the libs instead. But this is just really inconvenient I think, especially if I have many games and I decide to add another library to my engine. It's just maintenance for something so simple.

Should I stick to the .dll, or is there some way to fix this beauty up?

Thanks a lot,

Antoon


Solution

  • Did you create a different namespace to avoid naming clashes?

    EDIT -- seems like there is some confusion as to what you're asking, because you are asking a couple of questions.

    To me, it sounds like you want to take a stab at implementing your own Engine class. However, you've got naming issues. I am treating this as more of an architectural question now. If you write your Game to an interface, then the problem goes away. For example, if your Engine is using different algorithms, then if you had written an EngineInterface that the current Engine and YourEngine implemented, then you could easily use Strategy to flip between the different implementations on the fly. This is nice because you'll be able to see the differences in-game if you wire the preferences into the app.