Find the answer to your Linux question:
Results 1 to 7 of 7
hi, here is my problem Screenshot - 072312 - 13:54:35.jpg what I'm I doing wrong that makes it say undefined reference to GetInt. I am just starting comp sci so ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jul 2012
    Posts
    3

    Angry problem with compiling


    hi,

    here is my problemScreenshot - 072312 - 13:54:35.jpg

    what I'm I doing wrong that makes it say undefined reference to GetInt. I am just starting comp sci so any help would be appreciated.Screenshot - 072312 - 13:59:24.jpg.

    Here is my actual code

  2. #2
    Trusted Penguin Dapper Dan's Avatar
    Join Date
    Oct 2004
    Location
    The Sovereign State of South Carolina
    Posts
    4,628
    My 54 year old eyes aren't good enough to see what you've posted here. Can you copy and paste the output here? If really long, use Pastebin and a linky.
    Linux Mint + IceWM Registered:#371367 New Members: click here

  3. #3
    Administrator MikeTbob's Avatar
    Join Date
    Apr 2006
    Location
    Texas
    Posts
    7,864
    I'm with Dan, my slightly younger eyes can't see it either but I do see that you are trying to issue these commands from the "Desktop" directory. You are probably in the wrong directory. You need to "cd" into the correct directory where your files reside, wherever that may be. If your files are in /home/wolverinefan724/test then you need to

    cd /home/wolverinefan724/test
    Then try to issue your commands as previously posted
    I do not respond to private messages asking for Linux help, Please keep it on the forums only.
    All new users please read this.** Forum FAQS. ** Adopt an unanswered post.

    I'd rather be lost at the lake than found at home.

  4. #4
    Just Joined!
    Join Date
    Jul 2012
    Posts
    3
    [QUOTE=MikeTbob;898789]I'm with Dan, my slightly younger eyes can't see it either but I do see that you are trying to issue these commands from the "Desktop" directory. You are probably in the wrong directory. You need to "cd" into the correct directory where your files reside, wherever that may be. If your files are in /home/wolverinefan724/test then you need to

    cd /home/wolverinefan724/test
    Then try to issue your commands as previously posted[/QUOTe

    maybe i should have posted this along with my code. I am using a virtual machine and taking a Harvard University comp sci class online with its own version of linux. So I don't have my own directory just the one there for the student. Because of this I am pretty sure I "cd" into the right place because its the only place to cd into. In reply to the pictures if you click on them they get bigger, or are they still to small to see? If they are still to small can you explain how to get to pastebin since i am fairly new here.
    Thanks,
    wolverinefan724

  5. #5
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,307
    [quote]In reply to the pictures if you click on them they get bigger, or are they still to small to see?[quote]they get bigger, but marginally. too hard to read.

    [quote]If they are still to small can you explain how to get to pastebin since i am fairly new here.[/code]

    just go here and paste!

    http://pastebin.com/

    then copy the URL from the address bar here. you can replace the "http" in the url with "hxxp" to avoid getting blocked from posting URLS by the forum software.
    Last edited by atreyu; 07-24-2012 at 04:53 PM. Reason: fixed url

  6. #6
    Just Joined!
    Join Date
    Jul 2012
    Posts
    3
    hey,

    So when i pasted the url from pastebin into the insert image box it said that it was an invalid file even when i typed hxxp in front
    Last edited by wolverinefan724; 07-25-2012 at 03:50 PM. Reason: failed paste

  7. #7
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,307
    Quote Originally Posted by wolverinefan724 View Post
    hey,

    So when i pasted the url from pastebin into the insert image box it said that it was an invalid file even when i typed hxxp in front
    you don't need to use the insert image box, just type the text right into the body of your response.

    i think i got the URL in an email though:

    Code:
    #include <stdio.h>
    #include <cs50.h>
    
    
    int
    main(void)
    {
    
        // ask user for an interger
        printf(" I'd like an interger please: ");    
        int n;
        n = GetInt();
                
       // analyze user's input (somewhat inaccurately)
       if (n > 0)
           printf(" you picked a positive number!\n");
             
       else
           printf("you picked a negative number!\n");
          
    }
    so i think you need the GetInt function which is provided in the cs50.c library. i don't know if you already have this compiled for your system, but I did not. I got both cs50.c and cs50.h here:

    Index of /library/c/cs50-library-c-3.0/

    then compiled the static and shared lib:
    Code:
    gcc -c -ggdb -std=c99 cs50.c -o cs50.o
    ar rcs libcs50.a cs50.o
    gcc -shared -W1,-soname,libcs50.so.1 -o libcs50.so.1.0.1 cs50.o
    then copied the shared lib to my system:
    Code:
    cp libcs50.so.1.0.1 /usr/local/lib
    cd /usr/local/lib
    ln -s libcs50.so.1.0.1 libcs50.so
    ldconfig
    then compiled your code:
    Code:
    gcc -L/usr/local/lib -lcs50 -o your_prog your_prog.c
    i may have missed/forgotten a step somewhere. i got tips from this thread.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •