import winsup-2000-02-17 snapshot
This commit is contained in:
33
winsup/mingw/samples/simpledll/dll.c
Normal file
33
winsup/mingw/samples/simpledll/dll.c
Normal file
@@ -0,0 +1,33 @@
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
BOOL WINAPI
|
||||
DllMain (HANDLE hDll, DWORD dwReason, LPVOID lpReserved)
|
||||
{
|
||||
switch (dwReason)
|
||||
{
|
||||
case DLL_PROCESS_ATTACH:
|
||||
printf ("DLL Attached.\n");
|
||||
break;
|
||||
|
||||
case DLL_PROCESS_DETACH:
|
||||
printf ("DLL Detached.\n");
|
||||
break;
|
||||
|
||||
case DLL_THREAD_ATTACH:
|
||||
printf ("DLL Thread Attached.\n");
|
||||
break;
|
||||
|
||||
case DLL_THREAD_DETACH:
|
||||
printf ("DLL Thread Detached.\n");
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
Test ()
|
||||
{
|
||||
printf ("Test Function called!\n");
|
||||
}
|
||||
|
44
winsup/mingw/samples/simpledll/dll.cpp
Normal file
44
winsup/mingw/samples/simpledll/dll.cpp
Normal file
@@ -0,0 +1,44 @@
|
||||
//
|
||||
// This is a C++ version of the code in dll.c. NOTE that you need to put
|
||||
// extern "C" { ... } around DllMain or it will not be called when your
|
||||
// Dll starts up! (It will get name mangled as a C++ function and the C
|
||||
// default version in libmingw32.a will get called instead.)
|
||||
//
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
extern "C" {
|
||||
|
||||
BOOL WINAPI
|
||||
DllMain (HANDLE hDll, DWORD dwReason, LPVOID lpReserved)
|
||||
{
|
||||
switch (dwReason)
|
||||
{
|
||||
case DLL_PROCESS_ATTACH:
|
||||
cout << "Dll Attached" << endl ;
|
||||
break;
|
||||
|
||||
case DLL_PROCESS_DETACH:
|
||||
cout << "Dll Detached" << endl ;
|
||||
break;
|
||||
|
||||
case DLL_THREAD_ATTACH:
|
||||
printf ("DLL Thread Attached.\n");
|
||||
break;
|
||||
|
||||
case DLL_THREAD_DETACH:
|
||||
printf ("DLL Thread Detached.\n");
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
Test ()
|
||||
{
|
||||
printf ("Test Function called!\n");
|
||||
}
|
||||
|
||||
};
|
2
winsup/mingw/samples/simpledll/dll.def
Normal file
2
winsup/mingw/samples/simpledll/dll.def
Normal file
@@ -0,0 +1,2 @@
|
||||
EXPORTS
|
||||
Test
|
13
winsup/mingw/samples/simpledll/exe.c
Normal file
13
winsup/mingw/samples/simpledll/exe.c
Normal file
@@ -0,0 +1,13 @@
|
||||
#include <stdio.h>
|
||||
|
||||
extern void Test();
|
||||
|
||||
int main()
|
||||
{
|
||||
printf ("Program started.\n");
|
||||
Test ();
|
||||
printf ("Program ends.\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
14
winsup/mingw/samples/simpledll/jamfile
Normal file
14
winsup/mingw/samples/simpledll/jamfile
Normal file
@@ -0,0 +1,14 @@
|
||||
|
||||
Dll dll.dll : dll.c ;
|
||||
|
||||
ImportLib libdll.a : dll.def ;
|
||||
|
||||
|
||||
Main exe.exe : exe.c ;
|
||||
|
||||
LinkLibraries exe.exe : libdll.a ;
|
||||
|
||||
DEPENDS exe.exe : dll.dll ;
|
||||
|
||||
LINKFLAGS on exe.exe = $(LINKFLAGS) -L. ;
|
||||
|
23
winsup/mingw/samples/simpledll/makedll.bat
Normal file
23
winsup/mingw/samples/simpledll/makedll.bat
Normal file
@@ -0,0 +1,23 @@
|
||||
rem *** Create the import library for the dll ***
|
||||
dlltool --dllname dll.dll --def dll.def --output-lib libdll.a
|
||||
|
||||
rem *** Compile the dll ***
|
||||
gcc -c -o dll.o dll.c
|
||||
|
||||
rem *** Link the dll ***
|
||||
gcc -s -mdll -o dll.dll -Wl,--base-file,dll.b dll.o
|
||||
dlltool --dllname dll.dll --base-file dll.b --output-exp dll.e --def dll.def
|
||||
gcc -s -mdll -o dll.dll -Wl,--base-file,dll.b dll.o -Wl,dll.e
|
||||
dlltool --dllname dll.dll --base-file dll.b --output-exp dll.e --def dll.def
|
||||
gcc -s -mdll -o dll.dll dll.o -Wl,dll.e
|
||||
|
||||
rem *** Delete temporary files from dll linking ***
|
||||
del dll.b
|
||||
del dll.e
|
||||
|
||||
rem *** Compile exe, which uses dll. ***
|
||||
gcc -c -o exe.o exe.c
|
||||
|
||||
rem *** Link exe.exe, which uses dll.dll ***
|
||||
gcc -s -L. -o exe.exe exe.o libdll.a
|
||||
|
Reference in New Issue
Block a user