Problem REPLAY: when we run a program compiled in the C series language, we may receive this error, the corresponding C ++ standard library for GLIBC version 3.4.14 is not found.
Problem origin: first, we need to know that a program needs to be dynamically linked after it is loaded, and the dynamic link requires the glibc library of the corresponding version. But which version of glibc library is required for our executable files?
This version problem already exists in our Executable File ELF format. We can use the command to view the result.
[22: 10huangyk @ leetcode] $> strings numDistinct | grep GLIB
GLIBC_2.2.5
GLIBCXX_3.4.5
GLIBCXX_3.4.14
GLIBCXX_3.4
Now we can see the GLIB library version required for loading ELF files. When was the version information added?
Answer: It was added when the gcc program was compiled. That is to say, if the GLIBC library versions of the two platforms are different and the GCC versions are different, their binary files cannot be universal.
Q: Where can I find the local GLIBC library? How can we find the corresponding version?
Answer: The default dynamic link library is stored in/usr/lib64/libstdc ++. so.6. However, if we compile GCC ourselves, the location of the library files corresponding to libc and libc ++ will change. If our installation path is/usr/local/gcc4.8.3The corresponding library file location is/usr/local/gcc4.8.3/lib:/usr/local/gcc4.8.3/lib64.
Q: Why does the above error still occur when I have installed the GLIBC library?
Answer: Although we have installed the corresponding database, the connector cannot find the location of the new database. Then, find the corresponding file in the original directory/usr/lib64/libstdc ++. so.6. So,We need to use the environment variable LD_LIBRARY_PATH to specify the location of the dynamic link library.