How can I extract all .obj files from a .lib file? The only way I found is to extract one at once. Is there a way to automate it?
LIB.EXE /EXTRACT:member.obj Library.LIB
How can I extract all .obj files from a .lib file? The only way I found is to extract one at once. Is there a way to automate it?
LIB.EXE /EXTRACT:member.obj Library.LIB
This is the batch file that I ended up using with usage extract.bat mylib.lib
or extract.bat *.lib
even
@ECHO OFF
SETLOCAL EnableDelayedExpansion
:Loop
IF "%1"=="" GOTO Continue
FOR %%F in (%1) DO (
SET LIBFILE=%%F
SHIFT
@ECHO !LIBFILE!
FOR /F %%O IN ('lib.exe /LIST !LIBFILE! /NOLOGO') DO (
@SET OBJFILE=%%O
@ECHO !OBJFILE!
SET OBJPATH=%%~dO%%~pO
SET OBJNAME=%%~nO
IF NOT EXIST "!OBJPATH!" md !OBJPATH!
IF EXIST "!OBJFILE!" ECHO !OBJFILE! exists, skipping...
IF NOT EXIST "!OBJFILE!" lib.exe /NOLOGO !LIBFILE! "/EXTRACT:!OBJFILE!" "/OUT:!OBJFILE!"
)
)
GOTO Loop
:Continue
You could write a short program to do the calls for you using system(...)
-Function.
That still leaves you with the problem of generating a list of member object files, though.