Thread: Should I have to do -lc -lgcc -lc (-lc twice) when compiling?

  1. #1
    Registered User
    Join Date
    Jun 2009
    Posts
    101

    Should I have to do -lc -lgcc -lc (-lc twice) when compiling?

    I was having a problem where I was getting errors about missing symbols unless I arranged the order of my libraries like this while compiling:

    gcc hello.c -o hello -static -lc -lgcc -lc

    It appears that both libraries needed functions from each other. But, since order matters, I had to do this.

    Does this make sense? Is this right?

  2. #2

  3. #3
    Registered User
    Join Date
    Mar 2011
    Posts
    546
    yes, gcc has an option to force multipass but by default it is single pass. --start-group archives --end-group

  4. #4
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Why should you need to specify either of those libraries (-lc or -lgcc) at all?
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  5. #5
    Registered User
    Join Date
    Jun 2009
    Posts
    101
    Quote Originally Posted by Codeplug View Post
    >> Does this make sense?
    Here are some blurbs on single pass linkers:
    DJGPP FAQ -- DJGPP uses a one-pass linker
    https://computation.llnl.gov/casc/co...e/node319.html
    Thanks. That pretty much answers my question!

    Quote Originally Posted by brewbuck View Post
    Why should you need to specify either of those libraries (-lc or -lgcc) at all?
    I was cross compiling, and had to use -nostdlib to prevent linking to the build system's libc (had to point the linker to the target libc manually).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. compiling with g++
    By elninio in forum Linux Programming
    Replies: 18
    Last Post: 07-03-2008, 04:15 PM
  2. Compiling for DOS
    By Unregistered in forum C++ Programming
    Replies: 7
    Last Post: 07-18-2002, 05:48 AM
  3. compiling?????
    By FliX in forum C++ Programming
    Replies: 8
    Last Post: 05-31-2002, 09:21 AM
  4. Help with compiling
    By oyerth in forum C++ Programming
    Replies: 1
    Last Post: 03-18-2002, 08:17 PM
  5. Compiling with gcc
    By tiberiumwaster in forum Linux Programming
    Replies: 2
    Last Post: 03-11-2002, 04:27 AM