1

I'm having trouble figuring out the problem with my load function. here's the weird error I get (I've never seen something like it):

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

The thing is I have no idea whether or not I should compile dictionary.c in the first place on its own. The pset specs said that I could just use make speller but again, with Makefile that is also mentioned, I'm not sure what is going wrong.

What about the library part of makefile (i.e., LIBS =), should I put the library declarations in it or in dictionary.c?

I'm confused to the source of this error and I have a feeling it's not from buggy code as much as me not understanding how to use dictionary.c/speller.c/makefile together.

Also, at the end of this error code, it says

undefined reference to main 

so that's also a clue.

P.S: I executed make speller and it gave no errors at all.

Thanks for all your help!

2
  • Have you created a different file for this function? Because your #includes at top indicate that.
    – ChrisG
    Commented Jul 1, 2015 at 17:47
  • Oh, no. These are all the header files I used in "dictionary.c". I've only included the "load" function here. I still haven't implemented the code for the rest of the functions in "dictionary.c".
    – Xiggi
    Commented Jul 1, 2015 at 17:54

1 Answer 1

1

Try changing this

else if (strcmp(&c, "'") == 0)

into this

else if (c == '\'')

EDIT
Try running make speller instead of make dictionary

6
  • Nope, same error :s
    – Xiggi
    Commented Jul 1, 2015 at 17:59
  • And that else if (strcmp(&c, "\0") == 0) to that else if (c == '\0')
    – ChrisG
    Commented Jul 1, 2015 at 18:01
  • Still same error haha :s
    – Xiggi
    Commented Jul 1, 2015 at 18:04
  • Ohhhh. My mistake. Try running make speller instead of make dictionary.
    – ChrisG
    Commented Jul 1, 2015 at 18:07
  • Well, if I run "make speller" it doesn't give out any errors. I want to make sure my "load" function is okay in "dictionary.c" though. I'm confused how to check my progress in this pset for each of the functions in "dictionary.c" :s
    – Xiggi
    Commented Jul 1, 2015 at 18:11

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