i was tring to make a reader in C because i am new in this lenguage in win 7, i use all kind of library but nothing work. This is what i did:
#include "linkedlist.h"
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
FILE * fp;
char * line = NULL;
size_t len = 0;
ssize_t read;
fp = fopen("tableros.txt", "r");
if (fp == NULL)
exit(EXIT_FAILURE);
while ((read = getline(&line, &len, fp)) != -1) {
printf("Retrieved line of length %zu:\n", read);
printf("%s", line);
}
fclose(fp);
if (line)
free(line);
exit(EXIT_SUCCESS);
}
but this code give me the same error undefined reference to getline in c
, i really don t know what error could be, so i try with other library that i find here here is the other try, is the same code but with #define _POSIX_C_SOURCE >= 200809L || _XOPEN_SOURCE >= 700
:
#include "linkedlist.h"
#define _POSIX_C_SOURCE >= 200809L || _XOPEN_SOURCE >= 700
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
FILE * fp;
char * line = NULL;
size_t len = 0;
ssize_t read;
fp = fopen("tableros.txt", "r");
if (fp == NULL)
exit(EXIT_FAILURE);
while ((read = getline(&line, &len, fp)) != -1) {
printf("Retrieved line of length %zu:\n", read);
printf("%s", line);
}
fclose(fp);
if (line)
free(line);
exit(EXIT_SUCCESS);
}
so i really don t know what could be, here i gonna put a screenshot of my editor in the case that the problem could be a compiler or another thing that i didn t see :( :
here are the errors that C give me with more detail:
C:\Users\RAULDE~1\AppData\Local\Temp\cctm12ki.o tablero.c:(.text+0x78): undefined reference to `getline'
C:\Users\Raul del Rio\Desktop\archivos c sist oper\collect2.exe [Error] ld returned 1 exit status