Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Date: Thu, 20 Jun 2002 10:38:42 -0400 From: "Scott A. Smith" Subject: DLLs To: cygwin AT cygwin DOT com Message-id: MIME-version: 1.0 X-MIMEOLE: Produced By Microsoft MimeOLE V5.50.4807.1700 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7BIT Importance: Normal X-Priority: 3 (Normal) X-MSMail-priority: Normal Hello, I've been having lots of fun trying to figure out how to build DLLs. I should first mention that I have resisted putting declspec qualifiers of any type into my volumes of code, so I have to use a .DEF file to declare what is exported. From recent discussions on this list, I guess that currently one can just invoke the compiler with a few flags such as -shared and -Wl,--export-all-symbols to automatically create a .DEF file (or at least the proper exports table) and build a relocatable DLL that has the all the functions exported. I cannot find this documented anywhere, but I was able to copy a build of some other software and it seems to work fine. Excellent. My makefile target looks like $(DLL_NAME) $(DLL_EXP_LIB): $(DLL_OBJS) g++ -shared -Wl,--out-implib=$(DLL_EXP_LIB) \ -o $(DLL_NAME) $(DLL_OBJS) -Wl,--export-all-symbols $(DLL_LDLIBS) Now, amidst the other scattered documentation on building DLLs there are alternative methods mentioned. Some invoke dllwrap, dlltool, gcc and/or ld, and they must use some repeat build commands to get a .DEF file, .EXP file, .BASE file, and ultimately produce a relocatable DLL. It is all quite confusing, and AFAIK, no documentation spells out exactly what is happening in each of these steps. (Yes, I have looked at dllhelpers) For example, the Cygwin Users Guide on Building and Using DLLs says to do steps such as gcc -s -Wl,--base-file,mydll.base -o mydll.dll mydll.o -Wl,-e,_mydll_init AT 12 dlltool --base-file mydll.base --def mydll.def --output-exp mydll.exp --dllname mydll.dll gcc -s -Wl,--base-file,mydll.base,mydll.exp -o mydll.dll mydll.o -Wl,-e,_mydll_init AT 12 dlltool --base-file mydll.base --def mydll.def --output-exp mydll.exp --dllname mydll.dll gcc -Wl,mydll.exp -o mydll.dll mydll.o -Wl,-e,_mydll_init AT 12 dlltool --def mydll.def --dllname mydll.dll --output-lib mydll.a I agree it is convoluted, and I vaguely understand why that had to be done. As I recall, I had to make my .DEF file prior to this too, needed for dlltool (2nd command). Now for my questions. 1.) Is creation of a DLL using just gcc the preferred method now? It is certainly quite easy to use, but is this documented anywhere? It seems to automatically put in its own DLL entry point function as well? 2.) If trying to make a DLL with multiple commands, should one never use ld for linking (as I read on this list somewhere), but stick with gcc, such as in the example above? 3.) Is dllwrap supposed to just engulf the first 5 lines of the above example? 4.) Using this multiple command method, is there a way to get dlltool or dllwrap to automatically build a .DEF file so that one need not explictly use nm on the object files prior to these commands? 5.) Is dlltool and dllwrap to become obsolete? Are there man pages for dllwrap? My questions partially stem from a attempt to use the Dev-C++ IDE to manage the build. It automatically uses dllwrap, e.g. a target that looks like $(DLL_NAME): $(DLL_OBJS) $(DLLWRAP) --export-all --output-def $(DEFFILE) --driver-name c++ \ --implib $(DLL_EXP_LIB) $(DLL_OBJS) -o $(DLL_NAME) $(LIBS) The resulting DLL causes linker errors complaining about undefined references to libBasics_a_iname and _nm(int0_t *). Here "Basics" comes from the name of the DLL made/used. The man pages for ld is the only place I've found which mentions the suffix _iname and how any such names are not exported. 6.) Anyone know why it is producing the undefined reference errors? I've tried so many differnt flags to try to stop this, but nothing works. I'd just stick with one gcc line to make the DLL were it not for dllwrap being embedded in the IDE. It would be nice to know what the differences are. At least I been having fun, or so I keep telling myself. Thanks, Scott -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/