import libraries among various Win32 linkers

jay.krell at cornell.edu jay.krell at cornell.edu
Mon Oct 2 01:59:55 EDT 2000


>Sounds better than last time I checked. Or maybe I'm confusing things,
>and GNU ld would not accept "static" libraries (i.e. non-import .lib

Well, I really never use Gcc or Metrowerks, just VC, but I just tried and it
seems to work. (Considering that the Cygwin import .libs are basically
regular static .libs..)

add.c:
    int add(int i, int j) { return i + j; }
useadd.c:
    #include <stdio.h>
    int add(int i, int j);
    int main() { printf("%d\n", add(1, 2)); return 0;}

cl -c add.c
lib add.obj
gcc -c useadd.c -I/cygwin/usr/include
del .\a.exe
ld useadd.o add.lib /cygwin/lib/crt0.o /cygwin/lib/libcygwin.a
/cygwin/lib/libkernel32.a
.\a
3

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)
ld -v
GNU ld version 2.10.90 (with BFD 2.10.90)

>http://www.bcbdev.com/articles/vcdll.htm#step3

This web page gives a clear solution to reduce the problems: Make all
exported functions __stdcall and use a .def file. Though I think the .lib
format still varies, Coff vs. Omf. Though, cool, at the end:

"C++Builder 3.0 introduced a new command line utility called COFFtoOMF.EXE.
This utility can convert a Visual C++ import library to a C++Builder import
library. Furthermore, the program will automatically alias __cdecl functions
from the Visual C++ format to the C++Builder format. The automatic aliasing
can simplify Step 3 if the DLL exclusively uses the __cdecl calling
convention. "

 ..Jay

-----Original Message-----
From: Martin von Loewis <loewis at informatik.hu-berlin.de>
To: jay.krell at cornell.edu <jay.krell at cornell.edu>
Cc: python-list at python.org <python-list at python.org>
Date: Sunday, October 01, 2000 11:35 AM
Subject: Re: import libraries among various Win32 linkers


>> So if you generate the import libs with VC5, then VC5, VC6, Cygwin,
>> CodeWarrior can all consume them.
>
>
>Sounds better than last time I checked. Or maybe I'm confusing things,
>and GNU ld would not accept "static" libraries (i.e. non-import .lib
>files).
>
>As for BorlandC, see
>
>http://www.bcbdev.com/articles/vcdll.htm#step3
>
>So it seems GNU ld is actually ahead of the Borland tools...
>
>Anyway, thanks for posting your research results.
>
>Regards,
>Martin





More information about the Python-list mailing list