Question
I'm having trouble with compiling this c code. The code I'm trying to compile is called serialize.c #include #include #include #include helpers.h #define RAND_RANGE 4
I'm having trouble with compiling this c code.
The code I'm trying to compile is called serialize.c
#include
#include "helpers.h"
#define RAND_RANGE 4
/* NOTE: This program does nothing useful. It just reads from STDIN, emits * to STDOUT, and occasionally reports that it fails ... */ int main() { int retval = read_data();
srand(time(NULL)); if (retval < 0 || rand() % RAND_RANGE == 0) { printf("Failed "); return 1; } return 0; }
I also have helpers.h
#ifndef HELPER_H
#define HELPER_H
#define BUF_SIZE 1024
int read_data();
#endif
I also have helpers.c
#include
#include "helpers.h"
int read_data() { char buffer[BUF_SIZE]; int retval;
while ((retval = fread(buffer, 1, BUF_SIZE, stdin)) == BUF_SIZE);
return retval; }
When I run "gcc -Wall -o asdf serialize.c", I get the errors:
undefined reference to 'read_data'
and
error ld returned 1 exit status.
Why is that?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started