About "make" command during the installation of GCC

I am compiling GCC 9.3.0 under FreeBSD 12.3 (i386). It is OK when I type ./configure, but when I type gmake (BSD make is different from GNU Make, so I fetch one by typing pkg install gmake which is GNU make), the program throws the error output:

ld: error: unable to find library -lc
collect2: error: ld returned 1 exit status
gmake[3]: *** [Makefile:992: libgcc_s.so] Error 1
gmake[2]: *** [Makefile:18047: all-stage1-target-libgcc] Error 2
gmake[1]: *** [Makefile:23357: stage1-bubble] Error 2
gmake: *** [Makefile:991: all] Error 2


Therefore, I serched in Makefile for line 991, 18047, and 23357. They are the same command which is:

@r='${PWD_COMMAND}'; export r; \

After I saw the complaint of linker, I guess the error is because the Makefile didn't make the linker find libc.so. (By the way, this file is under /usr/lib directory.)

Overall, can I modify the command or the Makefile by some means to solve this problem?
Last edited on
In theory, the Makefile can be modified manually, but this one apparently was generated by Automake:
https://en.wikipedia.org/wiki/Automake

So, the Makefile.am, from which the Makefile was generated, would be the proper place to fix the problem...

See also:
https://stackoverflow.com/a/2531841

________________

Also, often you can give the ./configure script additional parameters. Try something like:
./configure --extra-ldflags="-L/path/to/extra/lib"

BTW: Another possible reason why linking "libc" can fail is when the linker is trying to link static C library, but your system only has the shared one available? Either that, or the architecture doesn't match.
Last edited on
Do you specifically need gcc-9.3? Will 9.4 do? If so:
 
sudo pkg install gcc-9.4.0_1


You can pass in compiler/linker flags on the command-line:
 
LDFLAGS="-L<path> -l<lib>" ./configure
@kigar64551 @kbw

Thanks for answering!
Topic archived. No new replies allowed.