dll的问题
谁能给个简单的例子,先编辑个dll和exe,让这个exe调用dll,最好用C编译的
How to create a dll
Here's an example. Cut and paste the following into a file named dllfct.h:
#ifdef BUILD_DLL
// the dll exports
#define EXPORT __declspec(dllexport)
#else
// the exe imports
#define EXPORT __declspec(dllimport)
#endif
// function to be imported/exported
EXPORT void tstfunc (void);
Cut and paste the following into a file named dllfct.c:
#include <stdio.h>
#include "dllfct.h"
EXPORT void tstfunc (void)
{
printf ("Hello\n");
}
Cut and paste the following into a file named hello.c:
#include "dllfct.h"
int main ()
{
tstfunc ();
return (0);
}
To create the dll and an executable that uses it, try the following:
gcc -c hello.c
gcc -c -DBUILD_DLL dllfct.c
gcc -shared -o tst.dll -Wl,--out-implib,libtstdll.a dllfct.o
gcc -o hello.exe hello.o -L./ -ltstdll