Mail Archives: cygwin/2002/08/19/21:47:34
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/
- Raw text -