I'm having a couple of issues including custom libraries in my program
I have my main.c
file and a library.c
(where all the functions are stored) and library.h
(where all the prototypes are stored).
In main.c
I'm placing #include "library.h"
but the functions don't get recognized when I try to compile.
Am I doing something wrong?
I'm using GCC to build the file.
test.c:
#include "library.h"
int main()
{
int num = 5;
sum(num);
}
library.c
#include "library.h"
int sum(int num)
{
return num + 5;
}
library.h
#ifndef LIBRARY_H
#define LIBRARY_H
#include <stdio.h>
int sum(int num);
#endif
Getting error:
C:\Users\Gabriel\Desktop\test.o:test.c|| undefined reference to `sum'|