0

When I run breakout.c with clang breakout.c it gives me "errors"

EDIT: I also run this with make breakout (removeing the row_space) and gives me this

'
breakout.c:(.text+0x1b8): undefined reference to `getWidthGeneric'
breakout.c:(.text+0x20f): undefined reference to `setLocation'
breakout.c:(.text+0x271): undefined reference to `getType'
breakout.c:(.text+0x29e): undefined reference to `removeGWindow'
breakout.c:(.text+0x2f8): undefined reference to `getXGeneric'
breakout.c:(.text+0x326): undefined reference to `getWidthGeneric'
breakout.c:(.text+0x360): undefined reference to `getWidthGeneric'
breakout.c:(.text+0x3b4): undefined reference to `getXGeneric'
breakout.c:(.text+0x403): undefined reference to `getYGeneric'
breakout.c:(.text+0x452): undefined reference to `getYGeneric'
breakout.c:(.text+0x486): undefined reference to `getHeightGeneric'
breakout.c:(.text+0x4c6): undefined reference to `getHeightGeneric'
breakout.c:(.text+0x514): undefined reference to `setLocation'
breakout.c:(.text+0x53f): undefined reference to `setLocation'
breakout.c:(.text+0x544): undefined reference to `waitForClick'
breakout.c:(.text+0x564): undefined reference to `newGLabel'
breakout.c:(.text+0x57c): undefined reference to `setFont'
breakout.c:(.text+0x591): undefined reference to `setColor'
breakout.c:(.text+0x5a3): undefined reference to `add'
breakout.c:(.text+0x5cc): undefined reference to `setLocation'
breakout.c:(.text+0x5df): undefined reference to `newGLabel'
breakout.c:(.text+0x5f7): undefined reference to `setFont'
breakout.c:(.text+0x60c): undefined reference to `setColor'
breakout.c:(.text+0x61e): undefined reference to `add'
breakout.c:(.text+0x647): undefined reference to `setLocation'
breakout.c:(.text+0x64c): undefined reference to `waitForClick'
breakout.c:(.text+0x657): undefined reference to `closeGWindow'
/tmp/breakout-38db23.o: In function `initBall':
breakout.c:(.text+0x6af): undefined reference to `newGOval'
breakout.c:(.text+0x6c7): undefined reference to `setColor'
breakout.c:(.text+0x6e2): undefined reference to `setFilled'
breakout.c:(.text+0x6f4): undefined reference to `add'
/tmp/breakout-38db23.o: In function `initScoreboard':
breakout.c:(.text+0x716): undefined reference to `newGLabel'
breakout.c:(.text+0x72e): undefined reference to `setFont'
breakout.c:(.text+0x743): undefined reference to `setColor'
breakout.c:(.text+0x755): undefined reference to `add'
breakout.c:(.text+0x77e): undefined reference to `setLocation'
/tmp/breakout-38db23.o: In function `updateScoreboard':
breakout.c:(.text+0x7da): undefined reference to `setLabel'
breakout.c:(.text+0x7f5): undefined reference to `getWidthGeneric'
breakout.c:(.text+0x81d): undefined reference to `getWidthGeneric'
breakout.c:(.text+0x85b): undefined reference to `getHeightGeneric'
breakout.c:(.text+0x883): undefined reference to `getHeightGeneric'
breakout.c:(.text+0x8c7): undefined reference to `setLocation'
/tmp/breakout-38db23.o: In function `detectCollision':
breakout.c:(.text+0x909): undefined reference to `getXGeneric'
breakout.c:(.text+0x931): undefined reference to `getYGeneric'
breakout.c:(.text+0x95f): undefined reference to `getGObjectAt'
breakout.c:(.text+0x9a8): undefined reference to `getGObjectAt'
breakout.c:(.text+0x9f1): undefined reference to `getGObjectAt'
breakout.c:(.text+0xa3e): undefined reference to `getGObjectAt'
/tmp/breakout-38db23.o: In function `initBricks':
breakout.c:(.text+0xaf4): undefined reference to `newGRect'
breakout.c:(.text+0xb19): undefined reference to `setColor'
breakout.c:(.text+0xb3b): undefined reference to `setColor'
breakout.c:(.text+0xb5d): undefined reference to `setColor'
breakout.c:(.text+0xb7f): undefined reference to `setColor'
breakout.c:(.text+0xba1): undefined reference to `setColor'
breakout.c:(.text+0xbbc): undefined reference to `setFilled'
breakout.c:(.text+0xbce): undefined reference to `add'
/tmp/breakout-38db23.o: In function `initPaddle':
breakout.c:(.text+0xc58): undefined reference to `newGRect'
breakout.c:(.text+0xc70): undefined reference to `setColor'
breakout.c:(.text+0xc8b): undefined reference to `setFilled'
breakout.c:(.text+0xc9d): undefined reference to `add'
clang: error: linker command failed with exit code 1 (use -v to see invocation)

What is this Mumbo Jumbo?

2
  • Complile using make command instead of clang i.e. make breakout or clang -ggdb3 -O0 -std=c99 -Wall -Werror -Wno-unused-variable -o breakout breakout.c -lcs -lm Jul 29, 2015 at 16:27
  • Is there a breakout.c in pset3? I've recently completed pset3 but it was Game of Fifteen, not breakout.
    – kkSkr
    May 5, 2016 at 9:14

3 Answers 3

1

I met the same problem with you, and I have solved it.

I guess you should use make breakout instead of clang. Similarly, if you add another file in the folder breakout, you should also edit the file named Makefile.

1

Make sure you include the SPL library like so:

// Stanford Portable Library
#include <spl/gevents.h>
#include <spl/gobjects.h>
#include <spl/gwindow.h>

and then to compile use:

clang -ggdb3 -O0 -std=c99 -Wall -Werror -Wno-unused-variable -o breakout breakout.c -lcs -lm

See the -lcs flag? It tells the compiler to link the pre-compiled spl library. I think you miss that and that's the reason for all those undefined functions. If this doesn't work either please post a screenshot of the terminal, with the command you type being visible.


If this answers your question please accept it by clicking the gray check-mark to the left, so that it becomes green. You can also vote it up by pressing the up arrow above the check-mark. And don't forget to keep coding!

0

I think you didn't include spl correctly. That's why the compiler is saying the functions aren't defined. The include lines for SPL should be as below, or it may be something else somewhere is screwing up these lines.

// Stanford Portable Library
#include <spl/gevents.h>
#include <spl/gobjects.h>
#include <spl/gwindow.h>
1
  • no, I did those correctley
    – Ani
    Jul 29, 2015 at 14:35

You must log in to answer this question.

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