Linking multiple static .lib files into one monolithic .lib file using VS2008 SP1 without extracting .lib files first

StackOverflow https://stackoverflow.com/questions/4436330

  •  09-10-2019
  •  | 
  •  

Question

A basic question I have during my other question is this: Without first extracting the .lib files using the LIB.EXE command, how to I combine all .obj archive members together to form one larger monolithic .lib file? If I use the LIB.EXE or LINK.EXE utilities, some .obj files are omitted, presumably because there are no symbols defined in the omitted .obj files that are required by any other .obj file.

Without downloading and installing additional non-Microsoft software, and without first extracting all .obj files first, how do I combine them together?

Was it helpful?

Solution

You can't.

Think of a static-link .lib file as just a zipfile or tarfile containing some object files.

So you will have to find out what the contents are using lib /list, then extract each object out (one by one, that's the tedious part) using lib /extract, and once you've got everything ready, you build your new .lib.

If you're handy with a scripting language (Perl, Python, ...) it wouldn't be too hard to automate this chore. You could do it with batch commands (look for "for /F"; you'll need it) if you prefer.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top