Pelles C forum
C language => Expert questions => Topic started by: RotateRight on January 02, 2008, 08:21:30 PM
-
Is is possible to combine import libraries?
What I would like to do is use polib or polink
to combine
kernel32.lib gdi32.lib user32.lib
and get something like mylib.lib.
Even better would be someway of
combining DEF files.
-
polib /OUT:mylib.lib kernel32.lib user32.lib gdi32.lib
-
Vortex,
Thanks for responding.
You of all people can help me figure this out.
Love your tools!
// Hello.c
#include <windows.h>
void EntryPoint(void);
void EntryPoint(void)
{
MessageBox(NULL, "Text", "Caption", MB_OK);
ExitProcess(0);
}
.. Compile.bat output
C:\Hello>set PATH=\PellesC\Bin
C:\Hello>set INCLUDE=\PellesC\Include;\PellesC\Include\Win
C:\Hello>pocc -Tx86-coff -Ot -W1 -Gz -Ze Hello.c
C:\Hello>polib /OUT:mylib.lib \PellesC\Lib\Win\kernel32.lib \PellesC\Lib\Win\use
r32.lib \PellesC\Lib\Win\gdi32.lib
POLIB: warning: '__NULL_IMPORT_DESCRIPTOR' already defined in 'KERNEL32.dll'; ig
noring definition in 'USER32.dll'.
POLIB: warning: '__NULL_IMPORT_DESCRIPTOR' already defined in 'KERNEL32.dll'; ig
noring definition in 'GDI32.dll'.
C:\Hello>polink /ENTRY:_EntryPoint@0 /NODEFAULTLIB /SUBSYSTEM:WINDOWS /OUT:Hello
.exe Hello.obj .\mylib.lib
POLINK: error: Symbol 'mylib:.idata$2' is multiply defined ('mylib.lib(USER32.dl
l)' and 'mylib.lib(KERNEL32.dll)').
C:\Hello>pause
Press any key to continue . . .
-
Another valiant effort.
; kernel32.def
LIBRARY kernel32
EXPORTS
"_ExitProcess@4"
; user32.def
LIBRARY user32
EXPORTS
"_MessageBoxA@16"
G:\>polib /OUT:mylib.lib /DEF:kernel32.def /DEF:user32.def /MACHINE:X86
G:\>polink /ENTRY:_EntryPoint@0 /NODEFAULTLIB /SUBSYSTEM:WINDOWS /OUT:Hello.exe
Hello.obj .\mylib.lib
WoHooh it compiled!!
But,
(http://img221.imageshack.us/img221/3311/hellomg6.png)
Looking at mylib.lib in notepad,
there is no reference to kernel32.
-
This is not possibly - today, at least.
Using multiple /DEF options to POLIB will combine all symbols seen, but only the last LIBRARY name will be used to build the import library; all symbols will be associated with this (DLL) LIBRARY name. The next release will warn about conflicting LIBRARY names from multiple module-definition files, but otherwise the current behaviour will remain.
Combining multiple import libraries (LIB files) also fails because of the non-unique symbol '__NULL_IMPORT_DESCRIPTOR' used by Microsoft (the failure comes at link time). This could possibly be fixed by special code, but since I don't think combining import libraries is very useful/important/interesting, I will not waste much time on this. If it's really easy to fix, I will add something in the next release, otherwise I will not bother...
-
Pelle,
Thanks for your response.
I was successful in in obtaining
my desired results by creating
import libraries from the def
files and using Microsoft Link.
Of course, this was not my desired
result, as I would have liked to
have used polink.
I hope that when you make any
future enhancements or fixes
to the linker, that you consider
revisiting this again.
Thanks again
-
Using multiple /DEF options to POLIB will combine all symbols seen, but only the last LIBRARY name will be used to build the import library; all symbols will be associated with this (DLL) LIBRARY name. The next release will warn about conflicting LIBRARY names from multiple module-definition files, but otherwise the current behaviour will remain.
I wonder if there is any workaround? Or has this ever been addressed?
POLIB: warning: LIBRARY name 'kernel32.dll' replaced by 'user32.dll' from module-definition file 'Build64.def'.
-
Hello,
Trying to combine multiple libraries with Polib Version 12.00.0 to create the Universal C Runtime import library :
POLIB: warning: No symbols added from 'api-ms-win-crt-convert-l1-1-0.dll'; this member will never be seen by the linker.