Hello everyone...
I've searched a lot for this but i can't really figure this out.
My project consists of 5 .c files and 4 .h headers. all in the same folder.
I compile them separately succesfully but when it comes to group compiling (gcc -o progname and all the code files in linux environment OR compile-all option in dev-c++) i have these errors in both occasions:

 C:\Users\user\...\main.o(.text+0x9a) In function `main': 
   [Linker error] undefined reference to `dhmiourgia_Words'
   [Linker error] undefined reference to `katastrofh_Words'
 C:\Users\user\...\main.o(.text+0x1fb) In function `InitialiseTree':
   [Linker error] undefined reference to `InsertWord' 
   ....

and it goes on and on being unable to identify ALL the functions i use in main.c, define in Words.h and implement in Words.c

I first thought i missed the header #include pre-processor order but as you can see here it is!
How can i overcome these errors?
Below is the code files where the problem lies, All advice welcome, thanks again

/* file: main.c */

#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>                /* for gettimeofday() */
#include "typos_stoixeiouDDA.h"
#include "Words.h"


void InitialiseTree(FILE *wordlist, typosWords W, int totalwordsin);
void SearchUpdateTree(FILE *wordlist, typosWords W);
void Results(typosWords W, int totalwordsin);


int main(void)
{  typosWords A;
   FILE *FirstList, *SecondList;
   char ap;
   char ylop='B';
   char arxeio[25];
   int totalwordsin=0;

    printf("Den exei dhmiourgithei ATD-Words\nDhmiourgia? (n/N gia epivevaiwsh)\n");
    fflush(stdin);
    ap=getchar();
    if((ap=='n')||(ap=='N')){
        do{
            printf("Epilekste ylopoihsh dendrou (A gia AVL, B gia BST)\n");
            fflush(stdin);
            ylop=getchar();
            if((ylop=='B')||(ylop=='A')){
                A=dhmiourgia_Words();

                printf("Dwse onoma arxeiou-listas leksewn pros anazithsh(ston idio ypofakelo!)\n");
                scanf(" %s ", arxeio);
                if((FirstList=fopen(arxeio, "r"))==NULL)
                    printf("Sfalma kata to anoigma tou arxeiou\n");
                InitialiseTree(FirstList, A, totalwordsin);
                fclose(FirstList);

                printf("Arxeio pros eksetash: RomeoAndJuliet.txt\n");
                if((SecondList=fopen("RomeAndJuliet.txt", "r"))==NULL)
                    printf("Sfalma kata to anoigma tou arxeiou\n");
                SearchUpdateTree(SecondList, A);
                fclose(SecondList);

                Results(A, totalwordsin);
                katastrofh_Words(&A);
            }
            else printf("Lathos apantisi\n");
        }while((ylop!='A')&&(ylop!='B'));
    }
    printf("Eyxaristoyme poy mas protimhsate!\n");
    return 0;
}

void InitialiseTree(FILE *wordlist, typosWords W, int totalwordsin)
{
    int i=0, res;
    char word[20];
    struct timeval start, t0, t1, t2, t3, t4, t5, t6, tALL;
    double elapsedTime;

    gettimeofday(&start, NULL);    /* start timer */
    do{
        res=fscanf(wordlist,"%s\n", word);
        InsertWord(W, word);
        i++;
        if(i==1024*(2^0))
            gettimeofday(&t0, NULL);    /* save time */
        if(i==1024*(2^1))
            gettimeofday(&t1, NULL);    /* save time */
        if(i==1024*(2^2))
            gettimeofday(&t2, NULL);    /* save time */
        if(i==1024*(2^3))
            gettimeofday(&t3, NULL);    /* save time */
        if(i==1024*(2^4))
            gettimeofday(&t4, NULL);    /* save time */
        if(i==1024*(2^5))
            gettimeofday(&t5, NULL);    /* save time */
        if(i==1024*(2^6))
            gettimeofday(&t6, NULL);    /* save time */
    }while(res!=EOF);

    totalwordsin=i;
    gettimeofday(&tALL, NULL);          /* save total time */

    /* calculating time for 1024*2^0 words to be inserted */
    elapsedTime = (t0.tv_sec - start.tv_sec) * 1000.0;      /* sec to ms */
    elapsedTime += (t0.tv_usec - start.tv_usec) / 1000.0;   /* us to ms */
    SetInsertTime(W, elapsedTime, 0);

    /* calculating time for 1024*2^1 words to be inserted */
    elapsedTime = (t1.tv_sec - start.tv_sec) * 1000.0;      /* sec to ms */
    elapsedTime += (t1.tv_usec - start.tv_usec) / 1000.0;   /* us to ms */
    SetInsertTime(W, elapsedTime, 1);

    /* calculating time for 1024*2^2 words to be inserted */
    elapsedTime = (t2.tv_sec - start.tv_sec) * 1000.0;      /* sec to ms */
    elapsedTime += (t2.tv_usec - start.tv_usec) / 1000.0;   /* us to ms */
    SetInsertTime(W, elapsedTime, 2);

    /* calculating time for 1024*2^3 words to be inserted */
    elapsedTime = (t3.tv_sec - start.tv_sec) * 1000.0;      /* sec to ms */
    elapsedTime += (t3.tv_usec - start.tv_usec) / 1000.0;   /* us to ms */
    SetInsertTime(W, elapsedTime, 3);

    /* calculating time for 1024*2^4 words to be inserted */
    elapsedTime = (t4.tv_sec - start.tv_sec) * 1000.0;      /* sec to ms */
    elapsedTime += (t4.tv_usec - start.tv_usec) / 1000.0;   /* us to ms */
    SetInsertTime(W, elapsedTime, 4);

    /* calculating time for 1024*2^5 words to be inserted */
    elapsedTime = (t5.tv_sec - start.tv_sec) * 1000.0;      /* sec to ms */
    elapsedTime += (t5.tv_usec - start.tv_usec) / 1000.0;   /* us to ms */
    SetInsertTime(W, elapsedTime, 5);

    /* calculating time for 1024*2^6 words to be inserted */
    elapsedTime = (t6.tv_sec - start.tv_sec) * 1000.0;      /* sec to ms */
    elapsedTime += (t6.tv_usec - start.tv_usec) / 1000.0;   /* us to ms */
    SetInsertTime(W, elapsedTime, 6);

    /* calculating time for all words to be inserted */
    elapsedTime = (tALL.tv_sec - start.tv_sec) * 1000.0;      /* sec to ms */
    elapsedTime += (tALL.tv_usec - start.tv_usec) / 1000.0;   /* us to ms */
    SetInsertTime(W, elapsedTime, 7);

    /* Reads words from wordlist(1)
       inserts into DDA/AVL using InsertWord after 1024, 2048, 4096,... words
       sets array times using SetInsertTime */
}

void SearchUpdateTree(FILE *wordlist, typosWords W)
{
    struct timeval start, end;
    double elapsedTime;
    int res;
    char word[20];

    gettimeofday(&start, NULL);    /* start timer */
    do{
        res=fscanf(wordlist,"%s\n", word);
        CheckWord(W, word);
    }while(res!=EOF);

    gettimeofday(&end, NULL);    /* stop timer */
    elapsedTime = (end.tv_sec - start.tv_sec) * 1000.0;      /* sec to ms */
    elapsedTime += (end.tv_usec - start.tv_usec) / 1000.0;   /* us to ms */
    SetCheckTime(W, elapsedTime);

    /* Reads words from wordlist(2)-RandJ
       calls CheckWord
       saves total Check time */
}

void Results(typosWords W, int totalwordsin)
{
    struct timeval start, end;
    double elapsedTime;
    char ap;
    int fileout;
    char arxeio[25];
    FILE* out;

    do{
        printf("Pathste O gia emfanisi apotelesmatwn sthn othoni\n");
        printf("        F gia emfanisi apotelesmatwn se arxeio keimenou\n");
        fflush(stdin);
        ap=getchar();

        if(ap=='O')
            fileout=0;
        else if(ap=='F'){
            fileout=1;
            printf("Dwse onoma arxeiou gia emfanisi apotelesmatwn (ston idio ypofakelo!)\n");
            scanf(" %s ", arxeio);
            if((out=fopen(arxeio, "w"))==NULL)
                printf("Sfalma kata to anoigma tou arxeiou\n");
        }
        else
            printf("Lathos apantisi\n");
    }while((ap!='O')&&(ap!='F'));

    gettimeofday(&start, NULL);    /* start timer */
    ShowCommonWords(out, W, fileout);
    gettimeofday(&end, NULL);    /* stop timer */

    elapsedTime = (end.tv_sec - start.tv_sec) * 1000.0;      /* sec to ms */
    elapsedTime += (end.tv_usec - start.tv_usec) / 1000.0;   /* us to ms */
    SetDiadromhTime(W, elapsedTime);
    fclose(out);

    PrintTimes(out, W, fileout, totalwordsin);
}





/* file: Words.c */



#include <stdlib.h>
#include <string.h>
#include <stdio.h>

#include "typos_stoixeiouDDA.h"
#include "Words.h"

#if ylop == 'B'
    #include "BST_pointer-Recursive.h"
#elif ylop == 'A'
    #include "AVL_pointer.h"
#endif


extern char ylop;

#if ylop == 'B'             /* Ylopoihsh tou ATD-Words me aplo DDA(BST) */
typedef struct RecWords 
{
     typos_deikti WordsRiza;  /* to Words apoteleitai apo to DDA */
     float InsertTime [10];   /* xronoi eisagvghs ana 1024, 2048,... (7 sto synolo)
                                kai o xronos eisagogis OLWN twn leksevn
                                apo to epilegmeno arxeio eisodoy */
     float CheckTime;         /* xronos anazhthshs OLWN twn leksevn
                                apo to epilegmeno arxeio eisodoy */
     float DiadromhTime;      /* xronos diadromhs */
} RecWords;

typosWords dhmiourgia_Words()
{
   typosWords WordsNew=malloc(sizeof(RecWords));
    Tree_dimiourgia(&(WordsNew->WordsRiza));
   return WordsNew;         
}

void katastrofh_Words(typosWords * Wordsptr)
{
   Tree_katastrofi(&(*Wordsptr)->WordsRiza);
   free(*Wordsptr);
   *Wordsptr=NULL;
}

void InsertWord(typosWords Words, char * w)
{
    TStoixeioyTree stoixeio;
    int* error=0;

    strcpy(stoixeio.word, w);
    stoixeio.frequency=0;

    Tree_eisagogi(Words->WordsRiza, stoixeio, error);

    if(*error) printf("Sfalma eisagogis stoixeioy sto dentro\n");
     /*Input w
        sets stoixeio DDA (kai ta 2 melh)
        calls eisagogi_komvou sto DDA 
    */
}

void CheckWord(typosWords Words, char * w)
{
    TStoixeioyTree stoixeio;
    int* error=0;
    int* found=0;
    typos_deikti* deiktis;

    strcpy(stoixeio.word, w);
    stoixeio.frequency=0;

    Tree_anazitisi(Words->WordsRiza, stoixeio, deiktis, found);
    if(*found) deiktis->frequency++;

    /* Input w
        sets stoixeio DDA (kai ta 2 melh)
        calls anazitisi_komvou and
        ??if found
            calls periexomena and set???
    */
}

void ShowCommonWords(FILE *out, typosWords Words, int fileout)
{
    Tree_endodiat(Words->WordsRiza, fileout, out);
    /* diadromh DDA me parametro function for testing if In2nd==1 */
}

/* praxeis poy diaxeirizontai toys xronoys */

void SetInsertTime(typosWords Words, float time, int position)
{
    Words.InsertTime[position]=time;
    /* Input time, position
        sets Words.InsertTime[position]=time;
    */
}

void SetDiadromhTime(typosWords Words, float time)
{   
    Words.DiadromhTime=time;
    /* Input time
        sets Words.DiadromhTime=time;
    */
}

void PrintTimes(FILE *out, typosWords Words, int fileout, int totalwordsin)
{
    int i;

    if(!fileout){
        for(i=0; i<=6 ; i++){
            printf("Xronos eisagogis %d leksewn sto Words:        %f\n", 1024*(2^i), Words->InsertTime[i]);
        }
        printf("Xronos eisagogis OLWN twn leksewn sto Words:        %f\n", Words->InsertTime[7]);
        printf("Xronos plhrous endodiatetagmenis diadromhs:         %f\n", Words->DiadromiTime);
        printf("Mesos xronos diadromis ana leksi:                   %f\n", (Words->DiadromiTime)/totalwordsin);
    }
    else{
        for(i=0; i<=6 ; i++){
            fprintf(out, "Xronos eisagogis %d leksewn sto Words:        %f\n", 1024*(2^i), Words->InsertTime[i]);
        }
        fprintf(out, "Xronos eisagogis OLWN twn leksewn sto Words:        %f\n", Words->InsertTime[7]);
        fprintf(out, "Xronos plhrous endodiatetagmenis diadromhs:         %f\n", Words->DiadromiTime);
        fprintf(out, "Mesos xronos diadromis ana leksi:                   %f\n", (Words->DiadromiTime)/totalwordsin);
    }
    /* emfanizei sthn othoni InsertTimes, DiadromhTime */
}

#elif ylop == 'A'   /* Ylopoihsh tou ATD-Words me AVL-Tree */

typedef struct RecWords
{
     typos_deikti WordsRiza;  /* to Words apoteleitai apo to AVL */
     float InsertTime [10];   /* xronoi eisagvghs ana 1024, 2048,... (7 sto synolo)
                                kai o xronos eisagogis OLWN twn leksevn
                                apo to epilegmeno arxeio eisodoy */
     float CheckTime;         /* xronos anazhthshs OLWN twn leksevn
                                apo to epilegmeno arxeio eisodoy */
     float DiadromhTime;      /* xronos diadromhs */
} RecWords;

typosWords dhmiourgia_Words()
{
   typosWords WordsNew=malloc(sizeof(RecWords));
    AVLTree_dimiourgia(&(WordsNew->WordsRiza));
   return WordsNew;
}

void katastrofh_Words(typosWords * Wordsptr)
{
   AVLTree_katastrofi(&(*Wordsptr)->WordsRiza);
   free(*Wordsptr);
   *Wordsptr=NULL;
}

void InsertWord(typosWords Words, char * w)
{
    TStoixeioyTree stoixeio;
    int* error=0;

    strcpy(stoixeio.word, w);
    stoixeio.frequency=0;

    AVLTree_eisagogi(Words->WordsRiza, stoixeio, error);

    if(*error) printf("Sfalma eisagogis stoixeioy sto dentro\n");
     /*Input w
        sets stoixeio AVL (kai ta 2 melh)
        calls eisagogi_komvou sto AVL
    */
}

void CheckWord(typosWords Words, char * w)
{
    TStoixeioyTree stoixeio;
    int* error=0;
    int* found=0;
    typos_deikti* deiktis;

    strcpy(stoixeio.word, w);
    stoixeio.frequency=0;

    AVLTree_anazitisi(Words->WordsRiza, stoixeio, deiktis, found);
    if(*found) deiktis->frequency++;

    /* Input w
        sets stoixeio AVL (kai ta 2 melh)
        calls anazitisi_komvou and
        ??if found
            calls periexomena and set???
    */
}

void ShowCommonWords(FILE *out, typosWords Words, int fileout)
{
    AVLTree_endodiat(Words->WordsRiza, fileout, out);
    /* diadromh DDA me parametro function for testing if In2nd==1 */
}

/* praxeis poy diaxeirizontai toys xronoys */

void SetInsertTime(typosWords Words, float time, int position)
{
    Words.InsertTime[position]=time;
    /* Input time, position
        sets Words.InsertTime[position]=time;
    */
}

void SetDiadromhTime(typosWords Words, float time)
{
    Words.DiadromhTime=time;
    /* Input time
        sets Words.DiadromhTime=time;
    */
}

void PrintTimes(FILE *out, typosWords Words, int fileout, int totalwordsin)
{
    int i;

    if(!fileout){
        for(i=0; i<=6 ; i++){
            printf("Xronos eisagogis %d leksewn sto Words:        %f\n", 1024*(2^i), Words->InsertTime[i]);
        }
        printf("Xronos eisagogis OLWN twn leksewn sto Words:        %f\n", Words->InsertTime[7]);
        printf("Xronos plhrous endodiatetagmenis diadromhs:         %f\n", Words->DiadromiTime);
        printf("Mesos xronos diadromis ana leksi:                   %f\n", (Words->DiadromiTime)/totalwordsin);
    }
    else{
        for(i=0; i<=6 ; i++){
            fprintf(out, "Xronos eisagogis %d leksewn sto Words:        %f\n", 1024*(2^i), Words->InsertTime[i]);
        }
        fprintf(out, "Xronos eisagogis OLWN twn leksewn sto Words:        %f\n", Words->InsertTime[7]);
        fprintf(out, "Xronos plhrous endodiatetagmenis diadromhs:         %f\n", Words->DiadromiTime);
        fprintf(out, "Mesos xronos diadromis ana leksi:                   %f\n", (Words->DiadromiTime)/totalwordsin);
    }
    /* emfanizei sthn othoni InsertTimes, DiadromhTime */
}


#endif







/* file: Words.h */


#ifndef __TYPOS_WORDS__ 
#define __TYPOS_WORDS__
#include <stdio.h>

/*orismos typou Words */
typedef struct RecWords * typosWords; 

/* epikefalides praxewn */

/* praxeis poy yloioyntai me praxeis DDA */
typosWords dhmiourgia_Words();
void katastrofh_Words(typosWords * Wordsptr);

void InsertWord(typosWords Words, char * w);
void CheckWord(typosWords Words, char * w);
void ShowCommonWords(FILE *out, typosWords Words, int fileout);

/* praxeis poy diaxeirizontai toys xronoys */
void SetInsertTime(typosWords Words, float time, int position);
void SetCheckTime(typosWords Words, float time);
void SetDiadromhTime(typosWords Words, float time);
void PrintTimes(FILE *out, typosWords Words, int fileout, int totalwordsin);
#endif

Edited 3 Years Ago by Tsaou

please zip up your project source files and attach them to your post along with the makefile you use. We don't want the compiler-generated files such as *.o so delete them before zipping.

Edited 3 Years Ago by Ancient Dragon

no makefiles.. just the project .dev for dev-C++

Oh, i also tried it linux environment:
The command lines are: gcc -c Words.c main.c and the three other soource code files that dont really have a problem

(no problem there)

then gcc -o Words.o main.o and the three object files from the compilation above

(here it pops the "undefined references")

Same thing with the single: gcc -o test Words.c main.c and the three other soource code files

(again it pops the "undefined references")

The functions are commented out. For example, look at line 17 in words.c

#if ylop == 'B'

Where is ylop defined?

Edited 3 Years Ago by Ancient Dragon

I believe I see where the problem lies. The local variable ylop is defined in main.c, inside the main() function, as a regular char variable. The problem is that the functions are being selected using conditional compilation, which is performed by the pre-processor, not the compiler per se.

The thing is, the preprocessor #if directive knows nothing of C language variables; it can only operate on those constants which are defined using the preprocessor itself. The preprocessor operates entirely at (or, to be strictly accurate, before) compile time, and run time variables cannot affect it. Using conditional compilation to set something at run time simply won't work.

Aside from the linkage problem, I noticed that in the InitialiseTree() function, you have several places where you are using 2^x to exponentiate the powers of two. The problem with this is that C doesn't have an exponentiation operator; the caret (^) is used for the exclusive-or operator instead. To exponentiate, you need to #include <math.h> and use the pow() function from the standard library, like so: pow(2, 0).

Also, you can significantly simplify that function by placing the repeated computations into loops, and moving the larger set of calculations to a utility function, like so:

void InitialiseTree(FILE *wordlist, typosWords W, int totalwordsin)
{
    int i=0, j, res;
    char word[20];
    struct timeval start, t[7], tALL;

    gettimeofday(&start, NULL);    /* start timer */
    do{
        res=fscanf(wordlist,"%20s\n", word);
        InsertWord(W, word);
        i++;
        for (j = 0; j < 7; j++)
        {
            if (i == (1024 * (int) (floor(pow(2, j)))))
                gettimeofday(&t[j], NULL);    /* save time */
        }
    }while(res!=EOF);

    totalwordsin=i;
    gettimeofday(&tALL, NULL);          /* save total time */

    for (j = 0; j < 7; j++)
    {
        calcElapsedTime(W, &start, &t[j], j);
    }

    calcElapsedTime(W, &start, &tALL, 7);
}


void calcElapsedTime(typosWords W, struct timeval* start, struct timeval* t, int offset)
{
    double elapsedTime;

    /* calculating time for all words to be inserted */
    elapsedTime = (t->tv_sec - start->tv_sec) * 1000.0;      /* sec to ms */
    elapsedTime += (t->tv_usec - start->tv_usec) / 1000.0;   /* us to ms */
    SetInsertTime(W, elapsedTime, offset);
}

This makes the function much easier to understand, and should make fixing and maintaining the code much simpler.

Edited 3 Years Ago by Schol-R-LEA

Ancient Dragon and Schol-R-LEA thanks a lot, looks like i was not so familiar with pre-processor orders!

Oh and thanks for the pow()thing i totally forgot ^ is just a symbol in C!
calcElapsedtime() is also something i really should have done!

ok here we go again...
Same error no macros,

WORDS.C

#include <stdlib.h>
#include <string.h>
#include <stdio.h>

#include "typos_stoixeiouDDA.h"
#include "Words.h"
#include "BST_pointer-Recursive.h"


typedef struct RecWords 
{
     typos_deikti WordsRiza;  /* to Words apoteleitai apo to DDA */
     float InsertTime [10];   /* xronoi eisagvghs ana 1024, 2048,... (7 sto synolo)
                                kai o xronos eisagogis OLWN twn leksevn
                                apo to epilegmeno arxeio eisodoy */
     float CheckTime;         /* xronos anazhthshs OLWN twn leksevn
                                apo to epilegmeno arxeio eisodoy */
     float DiadromhTime;      /* xronos diadromhs */
} RecWords;

typosWords dhmiourgia_Words()
{
   typosWords WordsNew=malloc(sizeof(RecWords));
    Tree_dimiourgia(&(WordsNew->WordsRiza));
   return WordsNew;         
}

void katastrofh_Words(typosWords * Wordsptr)
{
   Tree_katastrofi(&(*Wordsptr)->WordsRiza);
   free(*Wordsptr);
   *Wordsptr=NULL;
}

void InsertWord(typosWords Words, char * w)
{
    TStoixeioyTree stoixeio;
    int* error=0;
    typos_deikti* p=NULL;

    strcpy(stoixeio.word, w);
    stoixeio.frequency=0;

    p=&(Words->WordsRiza);
    Tree_eisagogi(p, stoixeio, error);

    if(*error) printf("Sfalma eisagogis stoixeioy sto dentro\n");
     /*Input w
        sets stoixeio DDA (kai ta 2 melh)
        calls eisagogi_komvou sto DDA 
    */
}

void CheckWord(typosWords Words, char * w)
{
    TStoixeioyTree stoixeio, neostoixeio;
    int* found=0;
    int*error=0;
    typos_deikti* deiktis;

    deiktis=malloc(sizeof(typos_deikti));

    strcpy(stoixeio.word, w);
    stoixeio.frequency=0;

    Tree_anazitisi(Words->WordsRiza, stoixeio, deiktis, found);
    Tree_periexomeno(Words->WordsRiza, &stoixeio, error);
    if(*error) printf("Dentro Keno\n");


    if(*found){
        *error=0;

        neostoixeio.frequency=stoixeio.frequency+1;
        strcpy(neostoixeio.word, w);

        Tree_allagi(&(Words->WordsRiza),stoixeio, neostoixeio, error);
        if(*error) printf("De vrethike h leksi pros allagi syxnothtas\n");
    }

    /* Input w
        sets stoixeio DDA (kai ta 2 melh)
        calls anazitisi_komvou
    */
}

void ShowCommonWords(FILE *out, typosWords Words, int fileout)
{
    EndoDiadromh(Words->WordsRiza, fileout, out);
    /* diadromh DDA me parametro function for testing if In2nd==1 */
}

/* praxeis poy diaxeirizontai toys xronoys */

void SetInsertTime(typosWords Words, float time, int position)
{
    Words->InsertTime[position]=time;
    /* Input time, position
        sets Words.InsertTime[position]=time;
    */
}

void SetDiadromhTime(typosWords Words, float time)
{   
    Words->DiadromhTime=time;
    /* Input time
        sets Words.DiadromhTime=time;
    */
}

void PrintTimes(FILE *out, typosWords Words, int fileout, int totalwordsin)
{
    int i;

    if(!fileout){
        for(i=0; i<=6 ; i++){
            printf("Xronos eisagogis %d leksewn sto Words:        %f\n", 1024*(2^i), Words->InsertTime[i]);
        }
        printf("Xronos eisagogis OLWN twn leksewn sto Words:        %f\n", Words->InsertTime[7]);
        printf("Xronos plhrous endodiatetagmenis diadromhs:         %f\n", Words->DiadromhTime);
        printf("Mesos xronos diadromis ana leksi:                   %f\n", (Words->DiadromhTime)/totalwordsin);
    }
    else{
        for(i=0; i<=6 ; i++){
            fprintf(out, "Xronos eisagogis %d leksewn sto Words:        %f\n", 1024*(2^i), Words->InsertTime[i]);
        }
        fprintf(out, "Xronos eisagogis OLWN twn leksewn sto Words:        %f\n", Words->InsertTime[7]);
        fprintf(out, "Xronos plhrous endodiatetagmenis diadromhs:         %f\n", Words->DiadromhTime);
        fprintf(out, "Mesos xronos diadromis ana leksi:                   %f\n", (Words->DiadromhTime)/totalwordsin);
    }
    /* emfanizei sthn othoni InsertTimes, DiadromhTime */
}

WORDS.H

#ifndef __TYPOS_WORDS__
#define __TYPOS_WORDS__

/*orismos typou Words */
typedef struct RecWords * typosWords; 

/* epikefalides praxewn */

/* praxeis poy yloioyntai me praxeis DDA */
typosWords dhmiourgia_Words();
void katastrofh_Words(typosWords * Wordsptr);

void InsertWord(typosWords Words, char * w);
void CheckWord(typosWords Words, char * w);
void ShowCommonWords(FILE *out, typosWords Words, int fileout);

/* praxeis poy diaxeirizontai toys xronoys */
void SetInsertTime(typosWords Words, float atime, int position);
void SetCheckTime(typosWords Words, float atime);
void SetDiadromhTime(typosWords Words, float atime);
void PrintTimes(FILE *out, typosWords Words, int fileout, int totalwordsin);
#endif

MAIN.C

#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>                /* for gettimeofday() */
#include <math.h>                    /* for pow() */
#include "typos_stoixeiouDDA.h"
#include "Words.h"


void InitialiseTree(FILE *wordlist, typosWords W, int totalwordsin);
void SearchUpdateTree(FILE *wordlist, typosWords W);
void Results(typosWords W, int totalwordsin);
void calcElapsedTime(typosWords W, struct timeval* start, struct timeval* t, int offset);


int main(void)
{  typosWords A;
   FILE *FirstList, *SecondList;
   char ap;
   char arxeio[25];
   int totalwordsin=0;

    printf("Den exei dhmiourgithei ATD-Words\nDhmiourgia? (n/N gia epivevaiwsh)\n");
    fflush(stdin);
    ap=getchar();
    if((ap=='n')||(ap=='N')){
        printf("Exei epilexthei ylopoihsh dentrou dyadikis anazitishs\n");

        A=dhmiourgia_Words();

        printf("Dwse onoma arxeiou-listas leksewn pros anazithsh(ston idio ypofakelo!)\n");
        scanf(" %s ", arxeio);
        if((FirstList=fopen(arxeio, "r"))==NULL)
            printf("Sfalma kata to anoigma tou arxeiou\n");
        InitialiseTree(FirstList, A, totalwordsin);
        fclose(FirstList);

        printf("Arxeio pros eksetash: RomeoAndJuliet.txt\n");
        if((SecondList=fopen("RomeAndJuliet.txt", "r"))==NULL)
            printf("Sfalma kata to anoigma tou arxeiou\n");
        SearchUpdateTree(SecondList, A);
        fclose(SecondList);

        Results(A, totalwordsin);
        katastrofh_Words(&A);
    }
    printf("Eyxaristoyme poy mas protimhsate!\n");
    return 0;
}

void InitialiseTree(FILE *wordlist, typosWords W, int totalwordsin)
{
    int i=0, res, j=0;
    char word[20];
    struct timeval start,t[7], tALL;

    gettimeofday(&start, NULL);    /* start timer */
    do{
        res=fscanf(wordlist,"%20s\n", word);
        InsertWord(W, word);
        i++;
        for (j = 0; j < 7; j++)
        {
            if (i == (1024 * (int) (floor(pow(2, j)))))
                gettimeofday(&t[j], NULL);    /* save time */
        }
    }while(res!=EOF);

    totalwordsin=i;
    gettimeofday(&tALL, NULL);          /* save total time */

   for (j = 0; j < 7; j++)
    {
        calcElapsedTime(W, &start, &t[j], j);       /* set 1024*2^j words insertion time */
    }
    calcElapsedTime(W, &start, &tALL, 9);           /* set all words insertion time */

    /* Reads words from wordlist(1)
       inserts into DDA/AVL using InsertWord after 1024, 2048, 4096,... words
       sets array times using SetInsertTime */
}


void calcElapsedTime(typosWords W, struct timeval* start, struct timeval* t, int offset)
{
    double elapsedTime;
    /* calculating time for all words to be inserted */
    elapsedTime = (t->tv_sec - start->tv_sec) * 1000.0;      /* sec to ms */
    elapsedTime += (t->tv_usec - start->tv_usec) / 1000.0;   /* us to ms */
    SetInsertTime(W, elapsedTime, offset);                  
}


void SearchUpdateTree(FILE *wordlist, typosWords W)
{
    struct timeval start, end;
    double elapsedTime;
    int res;
    char word[20];

    gettimeofday(&start, NULL);    /* start timer */
    do{
        res=fscanf(wordlist,"%s\n", word);
        CheckWord(W, word);
    }while(res!=EOF);

    gettimeofday(&end, NULL);    /* stop timer */
    elapsedTime = (end.tv_sec - start.tv_sec) * 1000.0;      /* sec to ms */
    elapsedTime += (end.tv_usec - start.tv_usec) / 1000.0;   /* us to ms */
    SetCheckTime(W, elapsedTime);

    /* Reads words from wordlist(2)-RandJ
       calls CheckWord
       saves total Check time */
}

void Results(typosWords W, int totalwordsin)
{
    struct timeval start, end;
    double elapsedTime;
    char ap;
    int fileout;
    char arxeio[25];
    FILE* out;

    do{
        printf("Pathste O gia emfanisi apotelesmatwn sthn othoni\n");
        printf("        F gia emfanisi apotelesmatwn se arxeio keimenou\n");
        fflush(stdin);
        ap=getchar();

        if(ap=='O')
            fileout=0;
        else if(ap=='F'){
            fileout=1;
            printf("Dwse onoma arxeiou gia emfanisi apotelesmatwn (ston idio ypofakelo!)\n");
            scanf(" %s ", arxeio);
            if((out=fopen(arxeio, "w"))==NULL)
                printf("Sfalma kata to anoigma tou arxeiou\n");
        }
        else
            printf("Lathos apantisi\n");
    }while((ap!='O')&&(ap!='F'));

    gettimeofday(&start, NULL);    /* start timer */
    ShowCommonWords(out, W, fileout);
    gettimeofday(&end, NULL);    /* stop timer */

    elapsedTime = (end.tv_sec - start.tv_sec) * 1000.0;      /* sec to ms */
    elapsedTime += (end.tv_usec - start.tv_usec) / 1000.0;   /* us to ms */
    SetDiadromhTime(W, elapsedTime);
    fclose(out);

    PrintTimes(out, W, fileout, totalwordsin);
}

commands and responses:

linux10:/.../BST>gcc -c Words.c typos_stoixeiouDDA.c main.c BST_pointer-Recursive.c
linux10:/.../BST>gcc -o BSTprog Words.o typos_stoixeiouDDA.o main.o BST_pointer-Recursive.o -lm
main.o: In function `SearchUpdateTree':
main.c:(.text+0x426): undefined reference to `SetCheckTime'
collect2: ld returned 1 exit status

Why just this one?
Whats wrong now?!

This question has already been answered. Start a new discussion instead.