Created
January 29, 2014 20:11
-
-
Save doi-t/8695964 to your computer and use it in GitHub Desktop.
makeでライブラリ(.a)のビルドを管理するサンプル(gccとg++の混在ver)
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 "hello.h" | |
int | |
print_hello(void) | |
{ | |
printf("hello gnu ar world !!\n"); | |
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
#ifndef ___hello | |
#define ___hello | |
#include <stdio.h> | |
#ifdef __cplusplus | |
extern "C" { | |
#endif | |
int print_hello(void); | |
#ifdef __cplusplus | |
} | |
#endif | |
#endif //___hello |
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
CC := gcc | |
RM := rm -f | |
CFLAGS := -Wall | |
CXXFLAGS := -Wall | |
programs := run | |
.PHONY: all | |
all: $(programs) | |
$(programs): libhello.a | |
libhello.a: libhello.a(hello.o) | |
hello.o: hello.h | |
.PHONY: clean | |
clean: | |
$(RM) *.o *.a $(programs) |
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 "hello.h" | |
int | |
main(int argc, char **argv) | |
{ | |
print_hello(); | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment