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

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -