2

I'm trying to compile helpers.c (pset 3), but it doesn't compile successfully. It gives me the following error:

jharvard@appliance (~/Dropbox/pset3/find): make helpers
clang -ggdb3 -O0 -std=c99 -Wall -Werror    helpers.c  -lcs50 -lm -o helpers
/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)

Can you guys help me????

3

helpers.c doesn't have a main() function.

You should make find and that will compile both, helpers.c and find.c as per the Makefile:

find: find.c helpers.c helpers.h
    clang -ggdb3 -O0 -std=c99 -Wall -Werror -o find find.c helpers.c -lcs50 -lm

notice that making find depends on any changes to find.c, helpers.c, and/or helpers.h.

you could also make all. in the same Makefile:

all: find generate

which means that if you execute make all that will execute both make find and make generate.

also since the previous line is the first command in the Makefile, running just make will execute this command.

2

As the pset explains, you must compile the helper file as part of find, so the Makefile that is provided will do that.

So, rather than make helpers, you simply type make and it should work.

2

You have come to make helpers only because check50 might have prompted you a frown at :( helpers.c compiles. Whatever changes you make, compiler throws the same error. Because helpers.c doesn't have main() function. The error arises only because you might have changed the flow of distro code or added any additional function. Even if you have declared the same in helpers.h, the same error arises. Its better not to change the distro code or add any additional function. Actually I had added an extra function in my program, check50 said my program is wrong eventhough it worked good. Then I removed that extra function and changed the logic, check50 smiled :)

3
  • Not trying to censor you or prevent you from trying to help, but you do realize this question was asked in 2014, right? Oct 22 '16 at 16:02
  • This may help for others who search for the same question at present. That's why :) @YuriLaguardia Nov 17 '16 at 6:00
  • Yeah. Like me, right now. Nov 17 '16 at 19:37

You must log in to answer this question.

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