import libraries among various Win32 linkers

jay.krell at cornell.edu jay.krell at cornell.edu
Sun Oct 1 09:01:35 EDT 2000


>Huh? I need to look into this. The other Win32 compilers/linkers really
>generate/consume different import libraries? Visual C++ actually changed
the

>>For Windows, there is indeed no reason. I use gcc as a cross-compiler
>>(host=Solaris, target=i386-pc-mingw) myself. The only drawback is that
>>the resulting import library for python.dll won't be VC++
>>compatible.


The import libraries in Metrowerks CodeWarrior are Visual C++ 6.0 format.
Given the directory names, they are probably directly from the Win32 SDK.

The import libraries in a recent Cygwin I have installed strongly resemble
the Visual C++ 5.0 import libraries, but they differ in some incidental
ways, like using the name __head_libkernel32_a instead of the name
__IMPORT_DESCRIPTOR_KERNEL32 , using section names .idata$2,4,5,6,7 instead
of 2-6.

I ran Visual C++ dumpbin 5.10.7303 over said files.

I bet you can mostly interchange the .libs just fine. Maybe Cygwin doesn't
consume the VC6 format.
Drat, then again, no, not quite.

This:
#define stdout (-12)
void __stdcall WriteFile(int, const void*, int, int*, void*);

void Entry(void)
{
 int i;
 WriteFile(stdout, "Hello, world\n", sizeof("Hello, world\n") - 1,  &i, 0);
}

gcc -c hello.c
mwcc -c hello.c

consume VC5 import libs all works
---------
ld hello.o --entry _Entry /msdev5/vc/lib/kernel32.lib works
mwld -subsystem console -main _Entry hello.obj /msdev5/vc/lib/kernel32.lib
works

consume Cygwin and Metrowerks (VC6) import libs don't work
---------
cl hello.c -link -entry:Entry -subsystem:console -nodefaultlib
\cygwin\lib\libkernel32.a doesn't work
mwld -subsystem console -main _Entry hello.obj \cygwin\lib\libkernel32.a
doesn't work
copy "\program files\metrowerks\codewarrior\Win32-x86
Support\Libraries\Win32 SDK\KERNEL32.LIB"
ld hello.o --entry _Entry ./kernel32.lib doesn't work

native all work
---------
 cl hello.c -link -entry:Entry -subsystem:console -nodefaultlib kernel32.dll
mwld -subsystem console -main _Entry hello.obj "..\..\Win32-x86
Support\Libraries\Win32 SDK\KERNEL32.LIB"
ld hello.o --entry _Entry /cygwin/lib/libkernel32.a
all work

So if you generate the import libs with VC5, then VC5, VC6, Cygwin,
CodeWarrior can all consume them.
If you generate the import libs with Cygwin, they only work with Cygwin,
this is due to small bugs, fixable in Cygwin.
If you generate the import libs with CodeWarrior, I didn't try that,
probably just VC6 and CodeWarrior can consume.
VC5 seems a reasonable lowest denominator. Just for running
"lib -def:foo.def". Compilation, I haven't tried, but should work with any
compiler..

version info

cl is VC5 or VC6, varyingly.

>gcc -v
Reading specs from /cygwin/bin/../lib/gcc-lib/i686-pc-cygwin/2.95.2/specs
gcc version 2.95.2 19991024 (release-2)

>mwcc
Metrowerks C/C++ Compiler for Windows/x86.
Copyright (c)1995-1999 Metrowerks, Inc.
All rights reserved.
Version 2.3
Runtime Built: May 26 1999 17:53:15

>mwld
Metrowerks Linker for Windows/x86.
Copyright (c)1995-1999 Metrowerks, Inc.
All rights reserved.
Version 2.3
Runtime Built: May 26 1999 14:54:14

Consuming cygwin libkernel32.a generally linked successfully but the .exe
wouldn't run.
Consuming CodeWarrior/VC6 import libs with Cygwin didn't link.

 - Jay





More information about the Python-list mailing list