makefile
Posted on September 2, 2022
Tags: c
#include "mylib.h"
int main(int argc, char* argv[]){
char *g;
= "hello\n";
g (g)
cout}
void cout(char* str)
#include <stdio.h>
void cout(char* str){
("%s",str);
printf}
all: compile link
./a.outcompile: main.c prints.c
gcc -c main.c
gcc -c prints.clink: compile
gcc main.o prints.o
- all –depends-on–> compile link
- compile –depends-on–> main.c prints.c
- link –depends-on–> compile
- compile –depends-on–> main.c prints.c
Notice the only atomic or leaf dependencies are main.c prints.c
mylib.h
behaves like an interface, it holds the interface or placeholder of functioncout
- How does
mylib.h
knowcout
function is located inprints.c
?- ANSWER: It doesn’t, the
Makefile
is what links the placeholder ofcout
to it’s implementation in compiledprints.o
- ANSWER: It doesn’t, the
Static analysis to find dependencies doesn’t work without also analyzing the Makefile
linking the object files.
Doxygen tells you that a function like cout
exists somewhere but we dont know how or where it is implemented.