NO

Author Topic: Import Libraries  (Read 11210 times)

RotateRight

  • Guest
Import Libraries
« 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.

Offline Vortex

  • Member
  • *
  • Posts: 858
    • http://www.vortex.masmcode.com
Re: Import Libraries
« Reply #1 on: January 02, 2008, 09:10:37 PM »
Code: [Select]
polib /OUT:mylib.lib kernel32.lib user32.lib gdi32.lib
Code it... That's all...

RotateRight

  • Guest
Re: Import Libraries
« Reply #2 on: January 02, 2008, 09:21:10 PM »
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 . . .
« Last Edit: January 02, 2008, 10:06:17 PM by RotateRight »

RotateRight

  • Guest
Re: Import Libraries
« Reply #3 on: January 03, 2008, 08:18:48 AM »
Another valiant effort.

Code: [Select]
; kernel32.def

LIBRARY kernel32
EXPORTS
"_ExitProcess@4"

Code: [Select]
; user32.def

LIBRARY user32
EXPORTS
"_MessageBoxA@16"

Code: [Select]
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,



Looking at mylib.lib in notepad,
there is no reference to kernel32.



Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2266
    • http://www.smorgasbordet.com
Re: Import Libraries
« Reply #4 on: January 03, 2008, 07:36:40 PM »
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

RotateRight

  • Guest
Re: Import Libraries
« Reply #5 on: January 05, 2008, 02:14:25 AM »
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

Offline jj2007

  • Member
  • *
  • Posts: 536
Re: Import Libraries
« Reply #6 on: October 05, 2016, 03:38:42 AM »
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?

Code: [Select]
POLIB: warning: LIBRARY name 'kernel32.dll' replaced by 'user32.dll' from module-definition file 'Build64.def'.

Offline Vortex

  • Member
  • *
  • Posts: 858
    • http://www.vortex.masmcode.com
Re: Import Libraries
« Reply #7 on: December 03, 2023, 05:47:13 PM »
Hello,

Trying to combine multiple libraries with Polib Version 12.00.0 to create the Universal C Runtime import library :

Code: [Select]
POLIB: warning: No symbols added from 'api-ms-win-crt-convert-l1-1-0.dll'; this member will never be seen by the linker.
Code it... That's all...