Bug 722216 - GCC error while trying to statically link to libc.a
Summary: GCC error while trying to statically link to libc.a
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: glibc
Version: 6.1
Hardware: x86_64
OS: Linux
unspecified
medium
Target Milestone: rc
: ---
Assignee: Andreas Schwab
QA Contact: qe-baseos-tools-bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-07-14 16:22 UTC by josh.yggdrasil
Modified: 2016-11-24 16:13 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-07-15 06:26:41 UTC
Target Upstream Version:


Attachments (Terms of Use)

Description josh.yggdrasil 2011-07-14 16:22:48 UTC
Description of problem:
GCC (ld) error while passing -static flag for compilation


Version-Release number of selected component (if applicable):
$ gcc --version
gcc (GCC) 4.4.5 20110214 (Red Hat 4.4.5-6)
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ ld --version
GNU ld version 2.20.51.0.2-5.20.el6 20091009
Copyright 2009 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.


How reproducible:
Every time


Steps to Reproduce:
1.  Make a very simple program, with few or no deps other than libc, this one works;

$ cat hello.c 
#include <stdio.h>

int main(void) 
{
	printf("hello, world.\n");
	return 0;
}

2.  Try to compile the program
$ gcc -static -o hello hello.c


Actual results:
$ gcc -static -o hello hello.c
/usr/bin/ld: cannot find -lc
collect2: ld returned 1 exit status
(and no binary is produced)


Expected results:
$ gcc -static -o hello hello.c
$ ldd hello
        not a dynamic executable
$ ./hello
hello, world.


Additional info:
-libc.a is not in /usr/lib64, but libc_nonshared.a is, as is libc.so

-tried yum whatprovides /usr/lib64/libc.a, but no packages matched

-tried a sym link, from libc.a to libc_shared.a, but that just produced a different linking error...

-this works on prior versions of RH

Comment 2 Andreas Schwab 2011-07-15 06:26:41 UTC
Install glibc-static.


Note You need to log in before you can comment on or make changes to this bug.