When I compile, with "make find", the following code:

enter image description here

I get:

enter image description here

So, if I'm interpreting this correctly, there's an undefined reference to search on line 58 of find.c, which is -- if (search(needle, haystack, size))

I have no idea how to fix this. Thanks for the help.

1 Answer 1


The error message means the term "search" is not defined. Did you change the function name in helpers.c? It looks like you have "binarySearch" instead of "search".

  • Yes, I did it was -- search(int value, int values[], int n).
    – cignal
    Commented Jun 7, 2016 at 1:31
  • That's the problem. You are calling the function search in find.c. Since helpers.c is included in find.c's header file, the compiler is looking in helpers.c for the definition of search. It can't find it since you renamed it.
    – ronga
    Commented Jun 7, 2016 at 2:08
  • Okay, the spec says the following -- "...you may not change our declaration of search, but you may write a new, recursive function (that perhaps takes different parameters) that search itself calls." Does this mean I can add another search function, like -- binarysearch(int value, int values, int min, int max)
    – cignal
    Commented Jun 7, 2016 at 2:30
  • I declared a 2nd search function called binarysearch, as mentioned above, and I get the same "undefined reference to search" error?
    – cignal
    Commented Jun 7, 2016 at 3:39
  • That's because when the compiler reads the line search(int value, int values[], int n) in find.c it still can't find a function called search in helpers.c. Either change everything to search or change everything to binarysearch, you can't have both.
    – ronga
    Commented Jun 7, 2016 at 4:02

You must log in to answer this question.

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