C Create Library LIB


- Info:

- This tutorial shows how to create "C LIB" using different compilers and tools.

- This tutorial is based on http://www.cygwin.com/cygwin-ug-net/dll.html


- MinGW:

- Creata C:\Temp\Test.h, Test.c and Hello.c

- Start MSDOS

- gcc -c Test.c -o message.lib

- gcc -static Hello.c -L./ -lmessage -o hello.exe

- hello.exe


- Microsoft Compiler:

- Create C:\Temp\Test.c

- Start MSDOS

- cd C:\Temp

- cl /c Test.c

- lib Test.obj

- cl Hello.c Test.lib

- Hello.exe


- Microsoft Visual Studio 2008:

- Start MVS 2008 File New Project ... Visual C++ General Empty Project Name: MyProject OK

- RC on MyProject Properties... Configuration Properties General Project Defaults

Configuration Type: Static Library (.lib) OK

- RC on Source Files Add New Item... Code C++ File (.cpp) Name: Test.c Add Paste Test.c

- RC on Test.c Properties Configuration Properties C/C++ Advanced Compile As: Compile as C Code (/TC)

- Start Without Debugging Ctrl+F5



void hello(void);


#include <stdio.h>

#include "Test.h"

void hello(void) { printf("Hello from LIB!\n"); }



int main () {


return 0;