From: gunther DOT ebert AT ixos-leipzig DOT de (Gunther Ebert) Subject: Re: dll with c++ at Beta 17 16 Dec 1996 08:07:19 -0800 Sender: daemon AT cygnus DOT com Approved: cygnus DOT gnu-win32 AT cygnus DOT com Distribution: cygnus Message-ID: <32B539B5.3003.cygnus.gnu-win32@ixos-leipzig.de> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 3.0Gold (WinNT; I) Original-To: Kurt Hohm Original-Cc: gnu-win32 AT cygnus DOT com Original-Sender: owner-gnu-win32 AT cygnus DOT com Hi, to build a dll that uses c++ code successfully you have to do these things: 1) your dll needs an entry point. This is a function int WINAPI dllEntry(HANDLE hDll, DWORD reason, LPVOID reserved); which is supposed to do some initialization stuff on DLL process or thread attach. You cannot create a working dll without an entry point. If you don't need any dll initialization this function just has to return TRUE. 2) you must tell the linker what your entry point is. 3) you must tell the linker that it has to build a dll. 4) you must call the linker twice because a dll needs a relocation section. The first pass creates some relocation information and the second pass creates the actual dll. 5) you have to write a .def file that contains all name-mangled functions (but without the leading underscore) which you are going to export Your linker command lines have to look like ld --dll -e _dllEntry AT 12 -o jnk --base-file dll.base dlltool --dllname foo.dll --base-file dll.base --def foo.def --output-lib foo.a \ --output-exp foo.exp ld --dll -e _dllEntry AT 12 -o foo.dll foo.exp rm jnk dll.base Just some comments to your .def file: It is a little bit complicated to write a .def file for c++ functions because these functions are name-mangled. I have been using successfully this way to create .def files for c++ dlls: 1) add all object files to a temporary library ar rc temp.a 2) create a .def file automatically from the temporary library echo EXPORTS > foo.def nm temp.a | grep " [TC] " | sed '/ _/s// /' | awk '{print $3;}' >> foo.def 3) link the dll as described above Good luck, Gunther - For help on using this list, send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".