The GCC static compilation option prompts an error:/usr/lib/ld: cannot find-LC.

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.