Devlog #40 - 28/03/16I'm in balancing and release testing at the moment and ran into some issues with Visual Studio's linker this weekend. It might be of some interest to people.
I was fixing an issue with cutscenes and needed to make some new cpp files (the issue was if I had an npc walking off screen (or in general) if a dialog box then showed up the npc would stop moving). So I created the new cpp files, and added them to my Visual Studio project. Everything compiled fine up until the linking; I got the error
LNK1140: too many modules for program database; link with /PDB:NONE.
So ok. More issues. Lovely.
As I found out yesterday:
- A PDB file is the thing that holds your debugging information
- An object (.obj) is a module
- You can only have 4095 modules in your PDB
Microsoft says to do the following for a solution:
- Relink using /PDB:NONE; or
- Compile some modules without debugging information; or
- Reduce the number of modules
By turning on PDB none, you remove all debugging information for you project. That's not what I wanted. I tried to turn off some modules without debugging information, but this would likely only be a patch solution; I'd run into it again as soon as I needed to add more cpp files. So clearly I needed to reduce the number of modules.
Except googling "LNK1140 reduce number of modules" gives 0 helpful results.
So first I counted how many obj files I actually have. There's 100 on the dot. Which means there's another 4000 coming from somewhere.... Well, not exactly, it's coming from libraries I'm importing. So outside of the obvious libraries I'm importing in my solution, there's also other ones in Properties > Linker > Input > Additional Dependencies. And some of them you can't remove because they're inherited. Thankfully you can ignore specific default libraries.
So I removed a few from the additional dependencies. It didn't fix the problem. Perhaps they weren't being used in the first place so they weren't being compiled into the PDB. I can't quite remove the .libs I need.
A suggestion online said to turn .lib projects in your solution into .dlls. Except everything that could be turned into a .dll in my solution was one to start. I tried turning a few .libs into .dlls but then I suddenly had compilation errors. I don't really wanna mess around with the game engine so I left it as a .lib.
Then I came across an option in Linker > General; you could output all the modules that were being linked. So I set it and watched. As expected, one of my libraries from the game engine was being added
a lot.
So, somehow the .objs from the library are being added. There's the other 4k .objs. Now how to get it to not do that. I can't convert it into a .dll. Thankfully I found an option for that.
That right there, Use Library Dependency Inputs, is the option you want to turn off. The description Microsoft gives is obtuse, but I came across it while trying to find a solution on
stackoverflow.
Essentially:
So, I set it to off, let it compile and everything linked perfectly.
I'm praying right now that this is a permanent fix to the problem, but I will likely see what the result is down the line when I have to add more cpps. If it doesn't fix it, well, I'll probably end up making another post about it. (And probably dealing with those .libs in additional dependencies.)
Follow-up