I'm using lab6.c as a driving program to test each. Before I split them up into their own files the functions did work. I'm supposed to create a custom library file. The steps I've taken was use wall to create an object file for each .c file in the folder and linked them together using ar rcs. I then used ar t liblab6(name of file) to verify that each object was linked to it. Keep getting a linking error "lab6.c:(.text+0x10): undefined reference to `str_len'".
It's the first function defined in my header file
#ifndef LAB_6_LIB_H
#define LAB_6_LIB_H
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
int all_letters(char *s);
Here's the .c file
#include "lab6lib.h"
int all_letters(char *s)
{
int i = 0;
while(s[i] != '\0'){
if(!isalpha(s[i]))
return 0;
i++;
}
return 1;
}
And here's the driver
#include "lab6lib.h"
#include <stdio.h>
int main(void)
{
int i = str_len("all");
printf("\n%d", str_len("all"));
printf("\n%d", str_len("hahahahahahahahahahahahah"));
printf("\n%d", all_letters("poop"));
printf("\n%d", all_letters("1haha"));
printf("\n%d", all_letters("SpongeBobby"));
}
Between reference materials from the class and what I could find online, I've defined it everywhere I should have. I even found a copy of this assignment from two years ago on github and the header, driver and c file all look the same as mine. I've been able to complete all the steps but I keep getting this error when linking.The only thing I haven't done is tried to compile this on my mac. Is there something I'm missing? Any help would be appreciated.