Find the answer to your Linux question:
Results 1 to 9 of 9
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    compilation error


    when i tried gcc,, i got the following error :


    /usr/bin/ld: cannot find -lc
    collect2: ld returned 1 exit status


    can somebody help me out,,, thanks in advance

  2. #2
    Just Joined!
    Join Date
    Mar 2007
    Location
    Bogotá, Colombia
    Posts
    46
    Hi!

    We're going to need a bit more than that. What are you compiling? Can you post a little more of the error that you're getting?

    As of right now, the only thing I can think of is to try an ldconfig (as root)

    Code:
    $ sudo ldconfig

  3. #3
    i was trying to compile a C program. even when i tried to print "hi":
    #include<stdio.h>
    void main()
    {
    printf("hi");
    }
    i got the error:
    /usr/bin/ld: cannot find -lc
    collect2: ld returned 1 exit status

  4. $spacer_open
    $spacer_close
  5. #4
    Just Joined!
    Join Date
    Mar 2007
    Location
    Bogotá, Colombia
    Posts
    46
    Well then, the error
    Code:
    collect2: ld returned 1 exit status
    means that either you didn't call all the libraries you need with the -l flag:
    e.g.
    Code:
    g++ -lMylibrary -o myprogram mycode.cpp
    or you just don't have the proper library installed.

    Check that you have all the basic libraries installed.

    EDIT: I just saw that the library ld is trying to find is the C library, you should start from there.

  6. #5
    Penguin of trust elija's Avatar
    Join Date
    Jul 2004
    Location
    Either at home or at work or down the pub
    Posts
    3,907
    What distro are you using? Have you installed the libraries for it?

    For Debian / Ubuntu and other Debian children you would run
    Code:
    sudo apt-get install build-essential
    Should you be sitting wondering,
    Which Batman is the best,
    There's only one true answer my friend,
    It's Adam Bloody West!


    The Fifth Continent

  7. #6
    thnx guyz,, problem solved

  8. #7
    Administrator MikeTbob's Avatar
    Join Date
    Apr 2006
    Location
    Texas
    Posts
    7,874
    Quote Originally Posted by rokala View Post
    thnx guyz,, problem solved
    Can you please tell us how you solved the problem? It may be helpful for others also.
    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.

  9. #8
    gcc was already installed in my pc,, but dint know why i got the errors(maybe i dint had the required libraries). So i re-installed gcc with the required libraries using synaptic manager and after that programs were compiled successfully. i am using UBUNTU 2.9 UE. is it okay mike ?

  10. #9
    Administrator MikeTbob's Avatar
    Join Date
    Apr 2006
    Location
    Texas
    Posts
    7,874
    Yes, that's very good. Thank you.
    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.

Posting Permissions

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