用mingw 創建DLL
如何用mingw 創建共享庫文件, 也就是DLL,過程如下所示:
/* shrobj.c 文件 */
const char *myfunc()
{
return "Hello World";
}
/* hello.c 文件 */
#include <stdio.h>
extern const char *myfunc();
main()
{
printf("%s\n", myfunc());
return 0;
}
編譯:
gcc -fpic -c shrobj.c
gcc -shared -o -fpic shared.dll shrobj.o
gcc -o hello.exe hello.c shared.dll
運行:
hello.exe
Hello World
posted on 2007-08-31 19:13 Normandy 閱讀(2064) 評論(3) 編輯 收藏 引用 所屬分類: Programming