1

When I run find, it reports that it finds the value when it's in the haystack, and reports that it didn't find it when it isn't. (i.e. it works according to the specification).

make find

works with no problem.

Yet check50 helpers.c reports:

    :) helpers.c exists
    :( helpers.c compiles
    \ expected an exit code of 0, not standard error of "helpers.c:18:6: error: conflicting type..."
    :| finds 42 in {42,43,44}
    \ can't check until a frown turns upside down
    :| finds 42 in {41,42,43}
     \ can't check until a frown turns upside down
    :| finds 42 in {40,41,42}
    \ can't check until a frown turns upside down
   :| finds 42 in {41,42,43,44}
   \ can't check until a frown turns upside down
   :| finds 42 in {40,41,42,43}
    \ can't check until a frown turns upside down
   :| finds 42 in {39,40,41,42}
    \ can't check until a frown turns upside down
   :| doesn't find 42 in {39,40,41}
   \ can't check until a frown turns upside down
   :| doesn't find 42 in {39,40,41,43}
   \ can't check until a frown turns upside down

when I try

make helpers

I get the following error message:

clang -ggdb3 -O0 -std=c11 -Wall -Werror -Wshadow    helpers.c  -lcs50 -lm -o helpers
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 0 has invalid symbol index 11
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 1 has invalid symbol index 12
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 2 has invalid symbol index 2
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 3 has invalid symbol index 2
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 4 has invalid symbol index 11
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 5 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 6 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 7 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 8 has invalid symbol index 12
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 9 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 10 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 11 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 12 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 13 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 14 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 15 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 16 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 17 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 18 has invalid symbol index 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 19 has invalid symbol index 21
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_line): relocation 0 has invalid symbol index 2
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [helpers] Error 1

What's going wrong?

1 Answer 1

1

The make helpers problem is easy. You can't do that. Somewhere in the source code, there has to exist a main() function. the helpers.c file by itself doesn't have it, so it generates all the errors that you saw. If you look inside the Makefile file, it has the build rules or instructions for the compiler/build program. The file find.c contains main, and the makefile contains the instructions to actually build and compile find. For more details, review the class material on make, makefile and generating executables.

As for what's happening with check50, I'm not sure. Clearly there's some kind of conflict. What is line i8 in helpers, and what starts at helpers.c, line 18 column 6? Also, what includes have you added to the program? What files have you changed besides helpers.c? I'm thinking that you have a type that might be defined in two different header files and they're conflicting. Without seeing any code at all, it's really hard to know what's happening.

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

5
  • helpers.c line 18 column 6 is where I start my search() function. bool search(int value, int values[], int min, int n) this function is also defined in helpers.h bool search(int value, int values[], int min, int n); helpers.c includes #include <cs50.h> #include <stdio.h> #include "helpers.h" helpers.h includes only #include <cs50.h> Feb 25, 2016 at 14:27
  • Are you sure the bool search function should have a parameter "int min"? My file helpers.h shows no such "int min" parameter.
    – jaguar
    Feb 26, 2016 at 20:21
  • That would explain it. By adding int min to the signature, it's creating conflicting signatures.
    – Cliff B
    Feb 26, 2016 at 21:15
  • Is having an extra parameter a problem? My code compiles and runs correctly when I've added the "min" parameter, but I got graded straight 0's when I uploaded it. If the conflicting signatures are tripping up check50, do I need to rewrite my program to receive credit? Mar 3, 2016 at 19:30
  • Yes, it's a problem. As stated in the instructions, "...know that you may not change our declaration of search..." meaning that you cannot add parameters. There is an important but hidden lesson here. In team programming environments, people are given parts of a project to do. Just like this, the parameters passed to and returned from a function will be fixed so that all the parts work together, but the programmers can do whatever they want inside the function to get the job done. So, yes, it's a major problem.
    – Cliff B
    Mar 3, 2016 at 20:21

You must log in to answer this question.

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