2

I wish anyone could give a clue on this: I've started the cs50 course, amazing!. But, I am not using the cs50 appliance, I use fedora 20 OS, got installed the cs50 library according guidelines but I can't help to get this output at one of the examples: [week 1, lecture continued, 44:44]

$ make condition0
cc     condition0.c   -o condition0
/tmp/ccYqPG01.o: In function `main':
condition0.c:(.text+0x16): undefined reference to `GetInt'
collect2: error: ld returned 1 exit status
make: *** [condition0] Error 1

Here the script as reference: I'd appreciate any help!

#include <stdio.h>
#include <cs50.h>

int main(void)
{
  printf("I'd like an int, please: ");
  int n = GetInt();
  if (n > 0)
    {
      printf("You picked a positive number.\n");
    }
  else if (n==0)
    {
      printf("You picked zero!\n");
    }
  else
    {
      printf("You picked a negative number.\n");
    }
}
6

First, you'll need to install the cs50 library. Follow this link for more information about how you can install the cs50 library on Fedora!

Second, you need to link the library binary file by providing -lcs50 when compiling. So your command should look something like

cc condition0.c -lcs50 -o condition0

Notice that you'll probably need a Makefile in case you decided to use make. A thing which I don't recommend you to confuse yourself with at least now. My advice to you is to try downloading and using the appliance because it makes things way easier since a lot of things are already configured for you.

| improve this answer | |
  • The cs50 appliance runs on a VMware app, it's a virtual software. I considered it not necessary, even a wasting of resources as I already do use fedora. Plus, not all machines, e.g. mine, support virtualization as it's documented on the VMplayer site. So I got, as said, installed cs50.h according guide, also gdb, clang. I Appreciate your help, anyway. – RS. Montalvo Oct 15 '14 at 12:49
  • @RS.Montalvo - I feel the same way. I have Ubuntu in my laptop already and would rather make things work within there rather than using CS50 appliance. This question helped me figure out an issue I was running into - thanks for asking the question here. – user6881 Apr 11 '15 at 19:37
  • Hi ! I am taking cs50 this year. can you please tell me how to install cs50.h in Ubuntu Linux ? Thanks a lot. :) – user8737703 Jun 17 '18 at 8:37

You must log in to answer this question.

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