I got 5 files that I'm trying to link using gcc on a raspberry pi, I have gone through a few posts and I cant seem to find the solution to this issue so I though I would ask and see if anyone can see what I'm doing wrong.
Got a make file that I run that looks like this
Mainfile:
gcc -c ./Include/func_1.c
gcc -c ./Include/func_2.c
gcc -c ./Include/func_3.c
gcc -c ./Include/func_4.c
gcc -c ./Include/func_5.c
gcc -c Mainfile.c
gcc -o Mainfile func_1.o func_2.o func_3.o func_4.o func_5.o Mainfile.o
Line 1 - 6 seem to work fine and I manage to make the object files but when I try to link them to the Mainfile in line 8 I get the following error
/usr/bin/ld: /tmp/cc5NQuqi.o: in function `main':
Mainfile.c:(.text+0xfc): undefined reference to `func1_1'
/usr/bin/ld: Mainfile.c:(.text+0x104): undefined reference to `func1_2'
/usr/bin/ld: Mainfile.c:(.text+0x10c): undefined reference to `func2_1'
/usr/bin/ld: Mainfile.c:(.text+0x114): undefined reference to `func2_2'
/usr/bin/ld: Mainfile.c:(.text+0x11c): undefined reference to `func3'
/usr/bin/ld: Mainfile.c:(.text+0x124): undefined reference to `func4_1'
/usr/bin/ld: Mainfile.c:(.text+0x12c): undefined reference to `func4_2'
/usr/bin/ld: Mainfile.c:(.text+0x134): undefined reference to `func5'
collect2: error: ld returned 1 exit status
make: *** [makefile:9: Mainfile] Error 1
Cant seem to figure out what is wrong with it.. got my func c files in the include folder along with their headers and I included the headers in the Mainfile and to test if it was the code I included the c files in the headers and then it builds fine.
Anyone have any idea what I'm doing wrong in my make file? First time trying to link so many files and using a make file so advice would be greatly appreciated.
Edit :
my main file looks something like
#include "./Include/func_1.h"
#include "./Include/func_2.h"
...
#include "./Include/func_5.h"
in main()
{
func1_1(argument);
...
func5_1(argument);
return 0;
}
my func_1.h files look something like
#ifndef FUNC_1_H
#define FUNC_1_H
// Argument check, is Host name and Port number default?
static void func1_1(int argument);
#endif
Then the func_1.c file looks something like
#include "math.h"
#include "func_1.h"
static void func1_1(int argument)
{
printf(argument + 1);
}