给你看从csdn里面找来的一段例子
//head file: asd.h
#ifdef _cplusplus
extern "C"{
#else
#endif
#ifdef HEAD_DLL
#define DLL_EXPORT _declspec(dllexport)
#else
#define DLL_EXPORT
#endif
int DLL_EXPORT asd_main(char* file_in, char* file_out);
#ifdef _cplusplus
}
#endif
//C file: asd.c
#include "asd.h"
int DLL_EXPORT asd_main(char* file_in, char* file_out)
{
FILE *in, *out;
in = fopen(file_in,"rb");
if(in == NULL)
return 0;
out = fopen(file_out,"wb");
if(out == NULL)
return 0;
//add code what you want:
......
}
然后编译的时候用一个生成dll的参数