Makefile Option Cflags,ldflags,libs

Source: Internet
Author: User

CFLAGS represents an option for the C compiler.

Cxxflags represents options for the C + + compiler.
These two variables actually cover the two steps of compiling and assembling.

CFLAGS: Specifies the path to the header file (. h file), such as: Cflags=-i/usr/include-i/path/include. Similarly, when a package is installed, an include directory is created under the installation path, and when a problem occurs during the installation, try adding the Include directory of the previously installed package to the variable.

Some of the optimization parameters used by the compiler, such as LDFLAGS:GCC, can also specify the location of the library files. Usage: ldflags=-l/usr/lib-l/path/to/your/lib. Each installation of a package will almost certainly create a Lib directory in the installation directory. If you install a package clearly, and install another package, it Leng said to find, you can express the Lib path of the package to join the Ldfalgs to try.

LIBS: Tell the linker which library files to link to, such as LIBS =-lpthread-liconv

Simply put, Ldflags is telling the linker where to look for library files, and Libs is telling the linker which library files to link to. However, when using the link stage these two parameters will be added, so you can even swap these two values, there is no problem.

Sometimes ldflags specifies-l Although the linker can find the library to link, but the runtime linker could not find the library, if you want to let the Software runtime library file path also extended, then we need to add the two libraries to "-wl,r":

Ldflags =-l/var/xxx/lib-l/opt/mysql/lib-wl,r/var/xxx/lib-wl,r/opt/mysql/lib

If you set the environment variable before you execute./configure export ldflags= "-l/var/xxx/lib-l/opt/mysql/lib-wl,r/var/xxx/lib-wl,r/opt/mysql/lib", Note Set environment variables there can be no spaces on either side of the equals sign, and enclose the quotation marks (shell usage). Then after the execution of configure, Makefile will set this option, the link will have this parameter, compiled executable program library file search path is extended.

Makefile Option Cflags,ldflags,libs

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.