'gcc undefined reference to header of multiple files

I have a sample code temp.c:

     #include "win.h"

win.h is in /home/me/Documents/Code/libs/TUI/win.h and has all the declared functions which functions are defined in some files in /home/me/Documents/Code/libs/TUI/win/[lots of files].c which every file starts with

    #include "../win.h"
    //functions 

So while using gcc -I /home/me/Documents/Code/libs/TUI /home/me/Documents/Code/temp.c -o /home/me/Documents/Code/temp, gcc returns every function used in temp.c declared in win.h as undefined

Exact output:

gcc -g -I/home/me/Documents/Code/libs/TUI /home/me/Documents/Code/temp.c -o /home/pk/Documents/Code/temp

/usr/bin/ld: /tmp/cc4berEn.o: in function `main':
/home/me/Documents/Code/temp.c:8: undefined reference to `innit'
/usr/bin/ld: /home/me/Documents/Code/temp.c:11: undefined reference to `newTable'
/usr/bin/ld: /home/me/Documents/Code/temp.c:13: undefined reference to `tableSetHeaders'
/usr/bin/ld: /home/me/Documents/Code/temp.c:35: undefined reference to `tableAppendRow'
/usr/bin/ld: /home/me/Documents/Code/temp.c:45: undefined reference to `printTable'
collect2: error: ld returned 1 exit status

notes

  • Using -I /home/me/Documents/Code/libs/TUI/win.h returns fatal error: win.h: No such file or directory 3 | #include "win.h"

  • /home/me/Documents/Code/libs/TUI is a folder

  • Writing every source file's name is not an option

  • Already tried this

  • -g for debug



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source