0

Right now, I have a modified version of a open-source dependency library (mylib.a file) in my project and thus I have it statically linked via gcc command(s). I am getting the error that...

"statically linked applications require at runtime the shared libraries from the glibc version used for linking"

My translation: my static dependency library cannot dynamically use glibc; it must also be compiled and dynamically linked. Thus, I'm trying to compile and statically link glibc.

I've gather that they would need to be compiled, the *.a library placed in a folder within the project, the "-I//location//" added in for the include headers, and the "-L//location//" added in for the libraries themselves.

But, for the question itself...

How to you compile glibc (32-bit and 64-bit)?

Through open-source research, I've found this link and I have cloned the repo but I cannot find any documentation on how to actually compile it.

git clone git://sourceware.org/git/glibc.git

Any thoughts or suggestions are welcomed.

Stryker2k2
  • 108
  • 9
  • 2
    No, you misunderstand the warning. It says "you are trying to statically link your program against glibc, beware, it doesn't work the way most people think it should". *Thus, I'm trying to compile and statically link glibc*. This is something you absolutely shouldn't do. It will waste a lot of your time and do nothing with the warning. Simply don't use `-static`. – n. m. could be an AI Oct 26 '21 at 17:12

1 Answers1

2

My translation: my static dependency library cannot dynamically use glibc; it must also be compiled and dynamically linked. Thus, I'm trying to compile and statically link glibc.

As n.m. pointed out, your translation is wrong.

You are trying to link a fully static executable, and GLIBC is warning you that such executable will not run correctly on any machine with a different version of GLIBC installed.

Instead of trying to build a fully-static executable, build it such that it uses libc.so.6 (you can still link mylib.a into such executable).

IF the reason you added -static to your link is that you have both libmylib.a and libmylib.so, and would like to link in the former instead of the latter, read this answer.

Employed Russian
  • 199,314
  • 34
  • 295
  • 362
  • After reading this comment a few weeks ago, I decided to fall down the rabbit hole of compiling and statically linking glibc; to include other third-party branches of glibc. I did, more or less, find a way to do it thanks to you comment, but ultimately decided to link dynamically. Compiling glibc would bloat my executable by double the size. Thank you for helping me out with this! <3 – Stryker2k2 Nov 16 '21 at 15:56