makefile
Posted on September 2, 2022
Tags: c
#include "mylib.h"
int main(int argc, char* argv[]){
char *g;
g = "hello\n";
cout(g)
}void cout(char* str)#include <stdio.h>
void cout(char* str){
printf("%s",str);
}all: compile link
./a.out
compile: main.c prints.c
gcc -c main.c
gcc -c prints.c
link: 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.hbehaves like an interface, it holds the interface or placeholder of functioncout- How does
mylib.hknowcoutfunction is located inprints.c?- ANSWER: It doesn’t, the
Makefileis what links the placeholder ofcoutto 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.