0

I was about to submit pset3 and pset4 which I have completed, but in the process of keeping my house in order by checking every code before submission, I discovered that helpers.c has developed issues. When I make find I receive this information from the compiler:

clang -ggdb3 -O0 -std=c11 -Wall -Werror -o find find.c helpers.c -lcs50 -lm
/tmp/find-b1555f.o: In function `main':
/home/ubuntu/workspace/pset3/find/find.c:55: undefined reference to `sort'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [find] Error 1

As a result, of course, it failed check50, which gave this advice:

helpers.c exists helpers.c compiles ! Fix the following dependencies first:   
helpers.c exists finds 42 in {42,43,44} ! Fix the following dependencies first:   
helpers.c compiles finds 42 in {41,42,43} !   Fix the following dependencies first:   
helpers.c compiles finds 42 in {40,41,42} !   Fix the following dependencies first:   
helpers.c compiles finds 42 in {41,42,43,44} !    Fix the following dependencies first:   
helpers.c compiles finds 42 in {40,41,42,43} !    Fix the following dependencies first:   
helpers.c compiles finds 42 in {39,40,41,42} !    Fix the following dependencies first:   
helpers.c compiles doesn't find 42 in {39,40,41}

Please, can someone be kind enough to advise me what to do. I have checked, all the files are intact. My only suspicion is the bubble sort code I wrote and cannot see why It should be complaining of it. Here, is a snipet of the code:

#include <stdio.h>
#include <cs50.h>

void BubbleSort(int values[], int n)
{
    // TODO: implement an O(n^2) sorting algorithm

    for (int i = values[n - 1]; i >= 0; i--)
    {
       for (int j = 0; j <= i; j++)
       {
           if (values[j - 1] > values[j])
           {
               int temp = values[j - 1];
               values[j - 1] = values[j];
               values[j] = temp;
           }
       }
    }
    return;
}

1 Answer 1

0

find calls functions sort and search, maybe you removed/renamed sort? It has to have the correct signature, too (same number and types of arguments).

4
  • Thank you. Yes, I did! The sort 0(0^2) sort function to be implement was: Commented Jan 11, 2017 at 14:20
  • Your generic sort function could call BubbleSort, QuickSort, or whatever you call your sort function. But find will call sort, does not have to know anything about the implementation you use.
    – Blauelf
    Commented Jan 11, 2017 at 14:22
  • thank you for your attention. I have changed it to just sort, but I noticed that the compiler is rejecting the semi-colon (;) after the functions name. If i remove it compiles, but check50 will still complain of dependencies. Just confused! Commented Jan 11, 2017 at 14:46
  • I think I have found what the problem is but I don't know how to go about solving it. Please, help! This is a snippet of my terminal window when I make all in pset3/find: Commented Jan 12, 2017 at 10:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .