1

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?

Community
  • 1
  • 1
bgoodr
  • 2,744
  • 1
  • 30
  • 51

1 Answers1

1

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.

  • Thanks tangobravomike. I have come to the same conclusions you have. In one case, I have scripted the extraction and re-linking of static libraries in the way you reference above, but that was a stop-gap to verify it works, and later I will remove the intermediate "monolithic" static library and try instead to do direct linkage to the subsidiary static libraries in the final DSO link, as it seems to me to be quite a bit less build overhead than "extracting then relinking" the monolithic lib. :) – bgoodr Jan 26 '11 at 17:44