1

I can't get the GetString() function from the cs50 library to work. I have tried update50 and have rebooted several times and it is still throwing out this error:

jharvard@appliance (~/Dropbox): make hello-2
g++     hello-2.C  -lcs50 -lm -o hello-2
/tmp/cckhwx2U.o: In function `main':
hello-2.C:(.text+0x16): undefined reference to `GetString()'
collect2: error: ld returned 1 exit status
make: *** [hello-2] Error 1

[Included code from comment]

#include <cs50.h>
#include <stdio.h>
int main(void)
{
    printf("Your name please: ");
    string name = GetString();
    printf("hello, %s\n", name);
}
8
  • Can we see the code?
    – i_am_david
    Commented Aug 13, 2015 at 18:13
  • //#include <cs50.h> #include <stdio.h> int main(void) { printf("Your name please: "); string name = GetString(); printf("hello, %s\n", name); }//
    – BoBbY
    Commented Aug 13, 2015 at 19:16
  • What appliance version are you using? It should say 2014-29 in the lower right corner.
    – curiouskiwi
    Commented Aug 13, 2015 at 22:12
  • You could also run appliance50 -v in a terminal window to find the appliance version.
    – i_am_david
    Commented Aug 14, 2015 at 1:51
  • Just to make sure, does the double slash (//) appears before #include <cs50.h> in your code (as in your comment)?
    – DavNej
    Commented Aug 14, 2015 at 18:29

1 Answer 1

1

I have this exact same problem.I have uploaded into the terminal the CS50 Library but this doesn't seem to have solved the issue. with either float or string

[Houndhill@localhost Documents]$ make hello cc hello.c -o hello /tmp/ccnCE1fi.o: In function main': hello.c:(.text+0x18): undefined reference toGetFloat' collect2: error: ld returned 1 exit status : recipe for target 'hello' failed make: *** [hello] Error 1 [Houndhill@localhost Documents]$

This is becoming very frustrating could you help please.

1
  • please post a new question, as the original post is 6 months old. (Seems you are not using a CS50 environment, so you are missing -lcs50 directive.) Commented Mar 6, 2016 at 23:59

You must log in to answer this question.

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