Why am I getting the following error message when I try to compile and how do I get rid of it?

jharvard@appliance (~/Dropbox/pset6): 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/lib/gcc/i686-redhat-linux/4.8.1/../../../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)

Because dictionary does not have int main () The purpose of dictionary.c is to hold the functions that are called upon by speller.c. Thus clang returns this error.

dictionary.h declares all the function prototypes that are in dictionary.c. If you #include "dictionary.h", it would be the same as #include <cs50.h> which gives you access to functions such as GetString().

speller.c has #include "dictionary.h" so that it can use the functions that are in dictionary.c. speller.c also has int main (). All these files are passed to clang when you type make. So either make or make speller would solve your problem.

You must log in to answer this question.

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