When learning GCC static library dynamic library compilation, when selecting static library compilation, an error is displayed:/usr/lib/ld: cannot find-lC
Baidu:/usr/lib/ld: cannot find-LC:
However, the problem cannot be solved, and the final location is found to be a problem of static compilation. This is not only the case:
/Usr/lib/ld: cannot find-lC
/Usr/lib/ld: cannot find-lgcc_s
/Usr/lib/ld: cannot find-LM
The main reason is that the static library needs to be linked during static compilation. The preceding command:
[[Email protected] app] $ gcc-static-I./libs main. C-o app-L./libs-lcrypto-lfunc
This is not the case if dynamic library compilation is selected when the-static option is removed during compilation.
[[Email protected] app] $ gcc-I./libs main. C-o app-L./libs-lcrypto-lfunc
[[Email protected] app] $ ls
APP libs main. c
LDD filename during non-static compilation is shown as follows, which is the dynamic library required by the executable program and required for running the executable program.
[[Email protected] app] $ LDD app
Linux-gate.so.1 => (0x004ad000)
Libcrypto. So =>/usr/lib/libcrypto. So (0x03ad9000)
Libfunc. So => not found
Libc. so.6 =>/lib/libc. so.6 (0x0052a000)
Libdl. so.2 =>/lib/libdl. so.2 (0x0070c000)
Libz. so.1 =>/lib/libz. so.1 (0x00713000)
/Lib/ld-linux.so.2 (0x00508000)
During static compilation, You need to link all the. A libraries to the executable files. Therefore, you need the libc static library file and find the glibc-static file in the system. Yum install glibc-static install static library.
The GCC static compilation option prompts an error:/usr/lib/ld: cannot find-LC.