1

I copied the source code for bounce.c and tried to compile it, but I got these errors. This also happens for other programs that use the SPL.

jharvard@appliance (~/new): make bounce
clang -ggdb3 -O0 -std=c99 -Wall -Werror    bounce.c  -lcs50 -lm -o bounce
/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'
/tmp/bounce-cf5d61.o: In function `main_':
/home/jharvard/new/bounce.c:21: undefined reference to `newGWindow'
/home/jharvard/new/bounce.c:24: undefined reference to `newGOval'
/home/jharvard/new/bounce.c:25: undefined reference to `setColor'
/home/jharvard/new/bounce.c:26: undefined reference to `setFilled'
/home/jharvard/new/bounce.c:27: undefined reference to `add'
/home/jharvard/new/bounce.c:36: undefined reference to `move'
/home/jharvard/new/bounce.c:39: undefined reference to `getXGeneric'
/home/jharvard/new/bounce.c:39: undefined reference to `getWidthGeneric'
/home/jharvard/new/bounce.c:39: undefined reference to `getWidthGeneric'
/home/jharvard/new/bounce.c:45: undefined reference to `getXGeneric'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [bounce] Error 1
jharvard@appliance (~/new): 

1 Answer 1

2

You need to link the spl library using the -l option. Your compilation command should look like this

clang -ggdb3 -O0 -std=c99 -Wall -Werror  bounce.c  -lcs50 -lcs -lm -o bounce

If you want to use make, a quick trick is to copy the Makefile from breakout and paste it into the same directory as your bounce.c, then open it, replace every occurrence of breakout to bounce, save it and try executing

make bounce
3
  • I did what you said @Kareem with the compilation command, and instead of getting a whole list of errors like what ahmed got, I get just one error message: "bounce.c:7:1: error: control reaches end of non-void function [-Werror, -Wreturn-type]" My code is: #include <spl/gevents.h> //#include <spl/gobjects.h> //#include <spl/gwindow.h> int main(void) { printf("asdf\n"); } If I include just one library or all 3, I get the same error.
    – user6577
    Mar 15, 2015 at 1:45
  • Oops, it won't let me edit for my second question. What do you mean by copy the makefile from breakout?
    – user6577
    Mar 15, 2015 at 1:56
  • @AustinKim this error is different. See this for more info!
    – kzidane
    Mar 15, 2015 at 7:16

You must log in to answer this question.

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