I am learning embedded C. I am trying but giving error. I think this error due to mingw64. I am sharing full code
main.c
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include "test/test.h"
int main()
{
Test_t *deneme = test_init(5);
int a = test_getCount(deneme);
printf("one %d", a);
test_updateCount(deneme, 10);
int b = test_getCount(deneme);
printf("two %d", b);
return 0;
}
test.h
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
typedef struct
{
int count;
} Test_t;
Test_t *test_init(int number);
void test_updateCount(Test_t *tester, int number);
int test_getCount(Test_t *tester);
test.c
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include "test.h"
Test_t *test_init(int number)
{
Test_t *deneme = malloc(sizeof(Test_t));
deneme->count = number;
}
void test_updateCount(Test_t *tester, int number)
{
tester->count = number;
}
int test_getCount(Test_t *tester)
{
return tester->count;
}
I am developing with VSCODE. test.c and test.h files is in directory ./test.
build command is gcc .\main.c -o main.exe
and build error
C:/ProgramData/chocolatey/lib/mingw/tools/install/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\user\AppData\Local\Temp\ccSxcYgu.o:main.c:(.text+0x13): undefined reference to `test_init'
C:/ProgramData/chocolatey/lib/mingw/tools/install/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\user\AppData\Local\Temp\ccSxcYgu.o:main.c:(.text+0x23): undefined reference to `test_getCount'
C:/ProgramData/chocolatey/lib/mingw/tools/install/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\user\AppData\Local\Temp\ccSxcYgu.o:main.c:(.text+0x4b): undefined reference to `test_updateCount'
C:/ProgramData/chocolatey/lib/mingw/tools/install/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\user\AppData\Local\Temp\ccSxcYgu.o:main.c:(.text+0x57): undefined reference to `test_getCount'
collect2.exe: error: ld returned 1 exit status