While compiling the C code as follows:
#include <stdio.h> // Notice the library included in the header of this file
#include <stdlib.h>
#include "myLibrary.h" // Notice that myLibrary.h uses different include syntax
#define MAX_LENGTH 21.8
#define WORK_WEEK 5
int main(void) {
function1();
return EXIT_SUCCESS;
}
I am getting the following:
d:/programs/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: C:\Users\svtte\AppData\Local\Temp\ccyHWfzC.o:02_01.c:(.text+0xc): undefined reference to `function1'
collect2.exe: error: ld returned 1 exit status
The myLibrary.h
file is as follows:
#ifndef MYLIBRARY_H_
#define MYLIBRARY_H_
void function1(void);
void function2(void);
#endif /* MYLIBRARY_H_ */
and myLibrary.c
is as follows:
void function1(void){
puts("It works :)");
}
void function2(void){
//This function does nothing as well
}
Any reasons as to why I am getting the error response would be helpful. Also, any pointers to the possible fixes would be great.