Last active
December 11, 2015 00:39
-
-
Save holys/4518153 to your computer and use it in GitHub Desktop.
简单版makefile
This file contains hidden or 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 <math.h> | |
| double compute(double x, double y) { | |
| return pow(x, y); | |
| } |
This file contains hidden or 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
| powe: power.o compute.o | |
| gcc power.o compute.o -lm -o powe | |
| power.o: power.c | |
| gcc -c power.c | |
| compute.o: compute.c | |
| gcc -c compute.c |
This file contains hidden or 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> | |
| double compute(double x, double y); | |
| int main() { | |
| float x, y; | |
| printf("The program takes x and y from stdin and displays x^y.\n"); | |
| printf("Enter integer x: "); | |
| scanf("%f", &x); | |
| printf("Enter integer y: "); | |
| scanf("%f", &y); | |
| printf("x^y is: %6.0f\n", compute(x, y)); | |
| return 0; | |
| } |
Author
Author
Make rules
target-list: dependency-list
<Tab>command-list
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
然后执行
make.执行过程:
注意:
makefile里面的-lm是compute.c用到了/usr/lib/libm.so的缘故.