C Library的做成

戻る

lib /? Microsoft (R) Library Manager Version 6.00.8168 Copyright (C) Microsoft Corp 1992-1998. All rights reserved. usage: LIB [options] [files] options: /CONVERT /DEBUGTYPE:CV /DEF[:filename] /EXPORT:symbol /EXTRACT:membername /INCLUDE:symbol /LIBPATH:dir /LINK50COMPAT /LIST[:filename] /MACHINE:{ALPHA|ARM|IX86|MIPS|MIPS16|MIPSR41XX|PPC|SH3|SH4} /NAME:filename /NODEFAULTLIB[:library] /NOLOGO /OUT:filename /REMOVE:membername /SUBSYSTEM:{NATIVE|WINDOWS|CONSOLE|WINDOWSCE|POSIX}[,#[.##]] /VERBOSE

程序和Header文件

// lib1.c #include <stdio.h> void cls(void) { printf("This is cls.\n"); } void locate(int x, int y) { printf("This is locate.\n", y+1, x+1); } void color(int n) { printf("This is color.\n", n); } // lib2.c #include <stdio.h> #include <stdlib.h> void putd(char *msg, int d) { printf("%s%d",msg,d); } int getd(char *msg) { char buf[20]; printf("%s", msg); return atoi(gets(buf)); } // lib1.h void cls(void); void locate(int x, int y); void color(int n); void putd(char *msg, int d); int getd(char *msg); // libtest1.c #include <stdio.h> #include "lib1.h" main() { int a; cls(); color(3); locate(0,5); a=getd("Please input a number:"); color(7); putd("The Number=",a); }

编译执行语句

C:\test>cl /c lib1.c C:\test>cl /c lib2.c C:\test>lib /out:libs.lib lib1.obj lib2.obj C:\test>lib /list libs.lib Microsoft (R) Library Manager Version 6.00.8168 Copyright (C) Microsoft Corp 1992-1998. All rights reserved. lib1.obj lib2.obj C:\test>cl libtest1.c libs.lib Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8168 for 80x86 Copyright (C) Microsoft Corp 1984-1998. All rights reserved. libtest1.c Microsoft (R) Incremental Linker Version 6.00.8168 Copyright (C) Microsoft Corp 1992-1998. All rights reserved. /out:libtest1.exe libtest1.obj libs.lib
戻る