c - GCC program undefined reference to function (multiple folders) -
i'm running undefined reference function during compilation. program:
main.c:
#include <stdio.h> #include "ssd/ssd.h" int main(void) { printf("%d\n",f()); return 0; }
ssd/ssd.h:
#ifndef ssd_h #define ssd_h int f(); #endif // ssd_h
ssd/ssd.c:
#include "ssd.h" int f(){ return 4; }
files ssd.h , ssd.c in folder ssd , file main.c , folder ssd in same folder. during compilation get:
[miku@mikutoshiba lab5]$ gcc main.c -o run /tmp/cc9x2i1h.o: in function `main': main.c:(.text+0xa): undefined reference `f' collect2: error: ld returned 1 exit status
i'm running fedora23
you build main.c
, though ssd/ssd.c
contains code well.
include in building process:
gcc ssd/ssd.c main.c -o run
Comments
Post a Comment