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 Message-ID: <3D5F1721.2808F1A3@gmx.net> Date: Sun, 18 Aug 2002 05:40:17 +0100 From: Lostmind X-Accept-Language: de,en MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: Problems exporting my DLL functions... Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hi, first: I'm a newbe in C programming, so don't eat me if the mistake is too simple - but at least it's not mentioned in the FAQ or in the short text on the Cygwin homepage about DLL stuff... Ok, what I want is to write a simple DLL... I definined two functions inside the DLL code, like this (I leave out the initialization code here): #ifdef __cplusplus #define EXPORT extern "C" __declspec (dllexport) #else #define EXPORT __declspec (dllexport) #endif EXPORT int CALLBACK CreateKeyboardHook (HWND receiver); EXPORT int CALLBACK DestroyKeyboardHook (); //... EXPORT int CALLBACK CreateKeyboardHook (HWND receiver) { //... } EXPORT int CALLBACK DestroyKeyboardHook () { //... } main() { } To compile I used the following instructions - based on the text from the Cywin homepage, but a bit modified (I wrote them in a .bat file): gcc -c khook.c -mno-cygwin -s -O3 gcc -Wl,--base-file,khook.base -o khook.dll khook.o -Wl,-e,_mydll_init AT 12 -mno-cygwin -O3 -s -luser32 dlltool --base-file khook.base --def khook.def --output-exp khook.exp --dllname khook.dll gcc -Wl,--base-file,khook.base,khook.exp -o khook.dll khook.o -Wl,-e,_mydll_init AT 12 -mno-cygwin -O3 -s -luser32 dlltool --base-file khook.base --def khook.def --output-exp khook.exp --dllname khook.dll gcc -Wl,khook.exp -o khook.dll khook.o -Wl,-e,_mydll_init AT 12 -mno-cygwin -O3 -s -luser32 dlltool --def khook.def --dllname khook.dll --output-lib khook.a My .def file looks like this: EXPORTS CreateKeyboardHook @1 DestroyKeyboardHook @2 When I run the batch, the first 3 instructions work fine but then gcc reports: khook.exp(.edata+0x34):fake: undefined reference to `CreateKeyboardHook' khook.exp(.edata+0x38):fake: undefined reference to `DestroyKeyboardHook' collect2: ld returned 1 exit status What's my mistake? Thanx for every answer... Klaus. -- 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/