Created
November 6, 2013 08:02
-
-
Save sillykelvin/7332505 to your computer and use it in GitHub Desktop.
A sample nmake project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include "share1.h" | |
#include "share2.h" | |
#include "static.h" | |
int main() { | |
printf("hello world\n"); | |
int a = 4; | |
int b = 2; | |
printf ("a: %d, b: %d\n", a, b); | |
printf("add: %d\n", add(a, b)); | |
printf("sub: %d\n", sub(a, b)); | |
printf("mul: %d\n", mul(a, b)); | |
printf("div: %d\n", div(a, b)); | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
shared_library: share1.c share2.c | |
cl /c share1.c share2.c | |
link share1.obj share2.obj /dll /out:share.dll /implib:share.lib | |
static_library: static.c | |
cl /c static.c | |
lib static.obj /out:static.lib | |
all: shared_library static_library main.c | |
cl /c main.c | |
link main.obj share.lib static.lib | |
clean: | |
del /F /Q *.exe *.dll *.lib *.obj *.exp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "static.h" | |
int mul(int a, int b) { | |
return a * b; | |
} | |
int div(int a, int b) { | |
return a / b; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef STATIC_H | |
#define STATIC_H | |
__declspec(dllexport) int mul(int, int); | |
__declspec(dllexport) int div(int, int); | |
#endif /* STATIC_H */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment