I'm trying to use the stat() function in the `#include <sys/stat.h> library however whenever I call it I get this error:
...toolchains/gcc-arm-none-eabi-8-2018/arm-gcc-macos/arm-none-eabi/lib/thumb/v6-m/nofp/libc_nano.a(lib_a-statr.o): in function `_stat_r':
statr.c:(.text._stat_r+0xe): undefined reference to `_stat'
Here is my file (I've listed all my includes, I know some might be not related to this problem but just incase I've listed all):
#include <kernel.h>
#include <device.h>
#include <drivers/i2c.h>
#include <sys/__assert.h>
#include <logging/log.h>
#include <sys/printk.h>
#include <soc.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#define SOURCE_FILE   "battery.gm.fs"
int write_to_dev(struct device* dev)
{
    struct stat st;
    int nSourceFile;
    char *pFileBuffer;
    stat(SOURCE_FILE, &st); // problematic line
    // other code here
}
Whenever I call write_to_dev() I'm getting this issue. I'm basing my code off page 17 of this link: https://www.ti.com/lit/an/slua801/slua801.pdf?ts=1595360845070&ref_url=https%253A%252F%252Fwww.google.com%252F Thanks for your help!
Edit: I'm using an STM32 chip with zephyr RTOS, and TI BQ27621 fuel gauge
 
    