1

I have spent days trying to understand what went wrong, but there is no answer to this on Stack Exchange or the web. The problem below comes from the first video walk-through in week 4 of CS50x, from edX, and is titled "Bounce." Again, I have watch the video a million times and checked all syntax. This is not a p-set problem, but I think there are many who are skipping all videos where one has to include the "Stanford Public Libraries." I do have the 2014 appliance with the new Vmware window not shown in the walk-through video "Bounce" by HarvardX's CS50X3, "Introduction to Computer Science." My code below is, to the best of my ability, correct with what is presented in the video. Unfortunately, I think the problem is with my appliance. On the bottom, right-hand corner, I have no IP address and it says " missing network adapter. I don't know if that has anything to do with my file failing to compile, but, if anyone could help, I would greatly appreciate it, thanks.

All hash tags and angle brackets had to be removed to display the following:

#include spl/gevents.h   
#include spl/gobjects.h
#include spl/gwindow.h

int main(void)
{
    GWindow window = newGWindow(320,240);    

    GOval circle = newGOval(0, 110, 20, 20);
    setColor(circle, "Black");
    setFilled(circle, true);
    add(window, circle);

    double velocity = 2.0;

    while (true)
    {
        move(circle, velocity, 0);

        if (getX(circle) + getWidth(circle) >= getWidth(window))
        {
            velocity = -velocity;
        }        

        else if (getX(circle) <= 0)        
        {
            velocity = -velocity;
        }  

        pause(10);           
    }
}

Here is the long error message that I get when I try to compile.

jharvard@appliance (~): 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-5fd343.o: In function `main_':
/home/jharvard/bounce.c:7: undefined reference to `newGWindow'
/home/jharvard/bounce.c:9: undefined reference to `newGOval'
/home/jharvard/bounce.c:10: undefined reference to `setColor'
/home/jharvard/bounce.c:11: undefined reference to `setFilled'
/home/jharvard/bounce.c:12: undefined reference to `add'
/home/jharvard/bounce.c:18: undefined reference to `move'
/home/jharvard/bounce.c:20: undefined reference to `getXGeneric'
/home/jharvard/bounce.c:20: undefined reference to `getWidthGeneric'
/home/jharvard/bounce.c:20: undefined reference to `getWidthGeneric'
/home/jharvard/bounce.c:25: undefined reference to `getXGeneric'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [bounce] Error 1
jharvard@appliance (~): 
0
1

Even I have faced the same problem. You cannot use the default Make command to compile programs which use the Stanford Portable Library. The default Make command doesn't link this library. That is the reason a different Makefile is provided when you download the pset3.zip which links spl. For personal use of spl, i execute -> clang file.c -o file -lcs -lm .This works, provided there are no errors. And the 'missing network adaptor' is not necessarily the culprit. Hope that helps :)

1
  • thank you! writing out the clang command by hand worked for me!
    – ordette
    Nov 13 '15 at 19:46

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