0

I'm testing out a basic program called getname that prompts the user for their name to store it in a string variable. However make doesn't seem to work.

This is make's output:

jharvard@ubuntu:~$ make getname
cc     getname.c   -o getname
/tmp/ccbnEu3b.o: In function `main':
getname.c:(.text+0x16): undefined reference to `GetString'
collect2: error: ld returned 1 exit status
make: *** [getname] Error 1

The program does work, however, when I manually type out clang. Some guidance on how to setup make would be nice.

3
  • 1
    Welcome to the CS50 Stack Exchange community! Are you using 2015 appliance (Ubuntu-based) to compile this? Or is this your "own" machine?
    – abelinux
    Jan 3 '15 at 14:33
  • 3
    Try "update50". I had the same issue. This fixed it.
    – Ibrahim
    Jan 3 '15 at 19:26
  • indeed @ibrahim , if this happened using the appliance, it seems like a bug in default make config. Which seems to be the case looking at the provided output, but nonetheless better check it first ;)
    – abelinux
    Jan 4 '15 at 1:35
1

I can assume that you have broken or not set CFLAGS and LDLIBS environment variables. In the same folder try to create a file called makefile and place the next lines inside it:

CC=clang
CFLAGS=-ggdb3 -O0 -std=c99 -Wall -Werror
LDLIBS=-lcs50 -lm

Then just call make:

make getname

for ABC ;)

You must log in to answer this question.

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