From: jt AT boxhill DOT com (Jason Tishler) Subject: Re: DLL: How to generate .def from UNIX src 27 Jan 1997 07:21:47 -0800 Approved: cygnus DOT gnu-win32 AT cygnus DOT com Distribution: cygnus Message-ID: <32ECC04B.3DF1.cygnus.gnu-win32@boxhill.com> References: <199701241057 DOT LAA93020 AT sp059 DOT cern DOT ch> Reply-To: jt AT boxhill DOT com Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------13D263A96B02" X-Mailer: Mozilla 3.0Gold (WinNT; I) Original-To: Valery Fine Original-CC: gnu-win32 AT cygnus DOT com Original-Sender: owner-gnu-win32 AT cygnus DOT com This is a multi-part message in MIME format. --------------13D263A96B02 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit > Does any body there can point me how one can generate a def files > from the source (C/C++) to make DLL's? I wrote a perl script that automatically generates the DLL definition file needed to build a C++ DLL. Perhaps it will meet your needs or at least be a good starting point. USAGE: ===== The following is the command line syntax for symbols.pl: symbols.pl [-i IgnoreFile] [-m|-l] [-o OutputFile] [-t TemplateFile] files ... where: -i => specifies ignorable regular expression file (one per line) -m => map of C++ names to C name-decorated names -l => list of C name-decorated names (default) -o => specifies output filename -t => specifies template filename The following demonstrates how I could use symbols.pl to create my defintion file called NtService.def: perl -S symbols.pl -i NtService.ignore -t NtService.template -o NtService.def NtService.obj OPTIONS: ======= The -i option specifies a file of regular expressions (one per line) that match symbols that you do NOT want to export. For example, here is my NtService.ignore: --- begin of NtService.ignore --- allocator basic_string char_traits list --- end of NtService.ignore --- Which shows that I want to ignore some symbols from the Standard Template Library. The -m and -l (default) options toggle between the map and list formats. The map format is just a tab separated list of the C++ names onto the name-decorated names -- it is intended to be human readable. The list format just lists the name-decorated names -- it is intended to be used to construct a DLL definition file. The -o option specifies the output file name. If not specified, then the output goes to standard output. The -t option specifies the template file which is just prepended to the output stream. For example, here is my NtService.template: --- begin of NtService.template --- ; ; $Id: NtService.template,v 1.1 1997/01/10 20:13:26 jt Exp $ ; ; NtService.def : Declares the module parameters for the DLL. LIBRARY "NtService" DESCRIPTION 'NtService Windows Dynamic Link Library' EXPORTS --- end of NtService.template --- MSVC++ Setup: ====== ===== 1. Add an .obj file to your project 2. Under "Build/Setting.../Custom Build/Win32 Debug" for the above .obj file add the following: Description: Performing Custom Exported Symbol Definition Step Build command(s): perl -S symbols.pl -i $(ProjDir)\NAME.ignore -t $(ProjDir)\NAME.template -o $(ProjDir)\NAME.def $(InputDir)\*.obj Output file(s): $(ProjDir)\NAME.def where: NAME is a name of your choice 3. Under "Build/Setting.../Custom Build/Win32 Release" for the above .obj file select "Exclude file from build." 4. Under "Tools/Options.../Directories/Executable files" add the path to perl. CAVEATS: ======= 1. symbols.pl needs a later version of perl for Win32 than the one supplied in the NT Resource Kit. I can supply an older version of symbols.pl that works with the Resource Kit's version of perl, if necessary. 2. Debug build must be built before Release builds (to (re)generate the definition file). 3. Debug builds will always rebuild the definition file and relink the DLL even if there were no changes to the source. MISC: ==== 1. symbols.pl is attached. 2. perl for Win32 can be found at ActiveWare (http://www.activeware.com/). 2. Do you know how to tell MSVC++ in "Build/Setting.../Custom Build" to use multiple input files to build one output file? 3. Please provide feedback on bugs, enhancements, etc. Enjoy, Jason -- Jason Tishler Phone: +1 (212) 989-4455 ext. 120 Box Hill Systems Corporation Fax: +1 (212) 989-6817 161 Avenue of the Americas Email: jt AT boxhill DOT com New York, NY 10013 USA WWW: http://www.boxhill.com --------------13D263A96B02 Content-Type: application/x-perl; name="symbols.pl" Content-Transfer-Encoding: base64 Content-Disposition: inline; filename="symbols.pl" cmVxdWlyZSAnZ2V0b3B0cy5wbCc7DQoNCnN1YiBNYWtlSWdub3JlUmUNCnsNCglteSgkZmls ZSkgPSBAXzsNCg0KCWlmICgkZmlsZSBlcSAiIikNCgl7DQoJCXJldHVybjsNCgl9DQoNCglv cGVuKElOUFVULCAkZmlsZSk7DQoJQGxpbmVzID0gPElOUFVUPjsNCgljbG9zZShJTlBVVCk7 DQoJY2hvcChAbGluZXMpOw0KCS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X3RcIiBmb3IgcmVhZFxuIjsNCglwcmludCBTVERPVVQgPFRFTVBMQVRFPjsNCn0NCg0KIyBD b25zdGFudCBkZWZpbml0aW9ucw0KJGlnbm9yZSA9IE1ha2VJZ25vcmVSZSgkb3B0X2kpOw0K JGR1bXBiaW4gPSAiZHVtcGJpbiAtc3ltYm9scyBAQVJHViI7DQoNCiMgUnVuIGR1bXBiaW4g YW5kIHNlbmQgcGFyc2VkIHN5bWJvbHMgaW5mb3JtYXRpb24gdG8gb3V0cHV0DQpvcGVuKERV TVBCSU4sICIkZHVtcGJpbnwiKTsNCndoaWxlICg8RFVNUEJJTj4pDQp7DQoJaWYgKC8oXFMr KSBcKChwdWJsaWN8cHJvdGVjdGVkKTogKC4rICk/X19cUysgKFteYF0rKVwpLykNCgl7DQoJ CWlmICgkNCAhfiAkaWdub3JlKQ0KCQl7DQoJCQlwcmludCBTVERPVVQgKCRvcHRfbSA9PSAx ICYmICRvcHRfbCAhPSAxKSA/ICIkNFx0JDFcbiIgOiAiXHQkMVxuIjsNCgkJfQ0KCX0NCn0N Cg0KIyBDbGVhbiB1cA0KY2xvc2UoRFVNUEJJTik7DQpleGl0IDA7DQo= --------------13D263A96B02-- - For help on using this list, send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".