I am new to Linux programming I tried to compile a simple test construction. But I'm getting an error when compiling. Adding inc.c as well (in the app: line) doesn't work. How should I include the file correct?
Makefile:
app: main.c inc.h
cc -o app main.c
Terminal:
make
cc -o app main.c
/tmp/ccGgdRNy.o: In function `main':
main.c:(.text+0x14): undefined reference to `test'
collect2: error: ld returned 1 exit status
make: *** [app] Error 1
main.c:
#include <stdio.h>
#include "inc.h"
int main()
{
printf("Kijken of deze **** werkt:
");
test();
getchar();
return 0;
}
inc.h
#ifndef INCLUDE_H
#define INCLUDE_H
void test();
#endif
inc.c
#include <stdio.h>
void test()
{
printf("Blijkbaar wel!");
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…