1

I am trying to build a C program using static flag (linking statically ). While I am trying to do so linker throws an error "can't find library for -lc". Machine I am using is HP-UX. I am unaware which library it requires and where I can find it so that I can include the default search location while building the program with -L option.

avotclbh:/home/akhils/test_prog#
avotclbh:/home/akhils/test_prog#gcc -v
Using built-in specs.
Target: ia64-hp-hpux11.31
Configured with: ../gcc/configure
Thread model: posix
gcc version 4.2.3
You have mail in /var/mail/root
avotclbh:/home/akhils/test_prog#


avotclbh:/home/akhils/test_prog#gcc -v -static test_debugging.c -o test_debugging.out -L/usr/lib/hpux64
Using built-in specs.
Target: ia64-hp-hpux11.31
Configured with: ../gcc/configure
Thread model: posix
gcc version 4.2.3
 /usr/local/libexec/gcc/ia64-hp-hpux11.31/4.2.3/cc1 -quiet -v test_debugging.c -quiet -dumpbase test_debugging.c -auxbase test_debugging -version -o /var/tmp//ccjCisnQ.s
ignoring nonexistent directory "NONE/include"
ignoring nonexistent directory "/usr/local/lib/gcc/ia64-hp-hpux11.31/4.2.3/../../../../ia64-hp-hpux11.31/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/local/lib/gcc/ia64-hp-hpux11.31/4.2.3/include
 /usr/include
End of search list.
GNU C version 4.2.3 (ia64-hp-hpux11.31)
        compiled by GNU C version 4.2.3.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 207e4f838aed34ece15d2a59ed6e0ca7
 /usr/local/bin/as -x -o /var/tmp//cceZpXhF.o /var/tmp//ccjCisnQ.s
 /usr/local/libexec/gcc/ia64-hp-hpux11.31/4.2.3/collect2 -z +Accept TypeMismatch -u main -noshared -o test_debugging.out crt0.o /usr/lib/hpux32/unix98.o -L/usr/lib/hpux64 -L/usr/local/lib/gcc/ia64-hp-hpux11.31/4.2.3 -L/usr/ccs/lib -L/usr/local/lib/gcc/ia64-hp-hpux11.31/4.2.3/../../.. /var/tmp//cceZpXhF.o -lgcc -lc -lgcc
**ld: Can't find library for -lc
Fatal error.
collect2: ld returned 1 exit status**
avotclbh:/home/akhils/test_prog#

Also, I have below dependencies already installed on machine

avotclbh:/home/akhils/test_prog#swlist -l product |grep -iE "gcc|zlib|libiconv|gettext"
  gcc                   4.2.3          gcc
  gettext               0.19.5.1       gettext
  libiconv              1.14           libiconv
  zlib                  1.2.8          zlib
avotclbh:/home/akhils/test_prog#
fuz
  • 88,405
  • 25
  • 200
  • 352
theartist33
  • 470
  • 1
  • 6
  • 13

1 Answers1

1

Install glibc library package.

alnet
  • 1,093
  • 1
  • 12
  • 24
  • glibc is not there for HP-UX I guess, could be libc which is already installed . Also I have manually linked libc.so if that's what linker is searching for but still not working. avotclbh:/home/akhils/test_prog#ll /usr/lib/hpux64/libc.so lr-xr-xr-x 1 bin bin 11 Mar 9 2015 /usr/lib/hpux64/libc.so -> ./libc.so.1 avotclbh:/home/akhils/test_prog# – theartist33 Dec 09 '15 at 13:07
  • I want to know which library exactly linker is looking for -lc flag ? – theartist33 Dec 09 '15 at 13:08
  • 1
    @theartist33 `-lc` makes the linker look for libc. – Filipe Gonçalves Dec 09 '15 at 13:09
  • Is `libc.so` located in the PATH? If not, you can add `-L` to the linker or run `ldconfig ` – alnet Dec 09 '15 at 13:10
  • @alnet : I did already what you said but I think what we should understand is that linker might not be looking for .so instead it is looking for .a (archive/static ) files because I am using -static flag while building up the C program. therefore i checked libc.so file is there but libc.a is not there. This could be the reason I guess ? – theartist33 Dec 09 '15 at 13:18