My question is why I cannot simply make a different version of label.c with another file name? Let's say I save it as labelTest1.c; I get this error:

jharvard@appliance (~/Dropbox/src5m): make labelTest1
clang -ggdb3 -O0 -std=c99 -Wall -Werror    labelTest1.c   -lcs50 -lm -o labelTest1
labelTest1.c:14:10: fatal error: 'gobjects.h' file not found

All .h files are in the same directory, same as label.c.

Here is a screen shot.

  • Can you show the first few lines of the labeltest1.c code please?
    – lethaljd
    Aug 11 '14 at 10:59

To make with different file name, we have to add a line into Makefile that is inside the same directory for example in my case:

labelTest1: labelTest1.c Makefile

clang -ggdb3 -Ispl/include -O0 -std=c99 -Wall -Werror -o labelTest1 labelTest1.c -Lspl/lib -lcs -lm  

See a screenshot:

enter image description here

Here is the screenshot when I run with make labelTest1.c

enter image description here


The cause of the error is that the compiler is unable to locate the gobjects.h header file. This file resides in the spl/include folder.

The other programs, such as label and breakout, can be compiled because the makefile instructions for the compiler (actually the pre-processor) on where to locate the .h files. You can see this working when you run make label, the command that executes is:

clang -ggdb -Ispl/include -O0 -std=c99 -Wall -Werror -o label label.c -Lspl/lib -lcs -lm

The relevant parts here are:

  1. -Ispl/include: Inform the pre-processor on where to look for additional .h files, including gobjects.h.
  2. -Lspl/lib: Instructs the linker to link in the spell binary code.

Notice that when you run make labelTest1, the above are not included, and so the pre-processor and the linker have no way of knowing where to find the relevant SPL headers and library file.

  • 1
    I figure out that I need to change the Makefile contents.
    – user1538
    Aug 11 '14 at 18:01

You must log in to answer this question.

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