Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin AT sources DOT redhat DOT com Message-ID: <3966D936.4FCEA748@ece.gatech.edu> Date: Sat, 08 Jul 2000 03:33:10 -0400 From: Charles Wilson X-Mailer: Mozilla 4.73 [en] (Windows NT 5.0; U) X-Accept-Language: en MIME-Version: 1.0 To: cygwin AT sourceware DOT cygnus DOT com Subject: YADLLQ: Yet Another DLL Question Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit I'm trying to build libpng-1.0.7 as a dll, and I'm running into link problems when building a application (okay, pngtest.exe). pngtest.pic.o(.text+0x54f):pngtest.c: undefined reference to `_imp__png_create_read_struct' and the like. (Note: ONE underscore preceeding the 'imp') Now, when building the dll, symbols (functions, actually) are declared thusly: __declspec(dllexport) type __cdecl symbol where 'type' is 'int *' or somesuch, and 'symbol' is the function itself. When compiling the object that is to be linked to the dll, the imported functions get declared like this: __declspec(dllimport) type __cdecl symbol --------------- Okay, so pngtest.pic.o (the object file importing stuff from the dll) has symbols like: U __imp__png_create_read_struct with 2 underscores preceeding the 'imp' However, the import library libpng.dll.a, contains symbols like: I ___imp_png_create_read_struct T _png_create_read_struct Note that the first one has 3 underscores preceeding the 'imp' The dll itself contains only T _png_create_read_struct ------------------ Since neither the import lib nor the dll contain '__imp_png_create_read_struct' with exactly 2 underscores, the link fails regardless of which one I try to link to. Why does the import lib have 3 underscores? What do the underscores mean? How do I make 'ld --shared' generate the implib with only two underscores? --Chuck P.S. I also observe that, in general, linking directly to a dll will fail, if the library headers are done 'correctly' with __declspec(dllimport). It's only when the headers are sloppy, and treat functions imported from the dll exactly as if they were coming from a static lib (that is, no __declspec at all) --- it's only in that case that linking directly to the dll will work. My intuition says this is probably why you can't import DATA when linking directly from a dll. DATA *must* be declared __declspec(dllimport).... -- Want to unsubscribe from this list? Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com