Makefile options CFLAGS, LDFLAGS, LIBS, cflagsldflags

Source: Internet
Author: User

Makefile options CFLAGS, LDFLAGS, LIBS, cflagsldflags
Makefile options CFLAGS, LDFLAGS, LIBS

CFLAGS indicates the options used in the C compiler,
CXXFLAGS indicates the options used for the C ++ compiler.
These two variables actually cover the compilation and compilation steps.

CFLAGS: Specifies the path of the header file (. h file), for example, CFLAGS =-I/usr/include-I/path/include. Similarly, when installing a package, an include directory will be created in the installation path. When there is a problem during the installation process, try to add the include directory of the previously installed package to this variable.

LDFLAGS: Gcc and other compiler will use some optimization parameters, you can also specify the location of the library file in it. Usage: LDFLAGS =-L/usr/lib-L/path/to/your/lib. Each package is installed with a lib directory. If a package is obviously installed, and when another package is installed, it cannot be found. You can try using the LDFALGS added to the lib path of the package.

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

To put it simply, LDFLAGS tells the linker where to find the library file, while LIBS tells the linker which library files to link. However, these two parameters are added during the link phase, so even if you swap these two values, there is no problem.

Sometimes, although LDFLAGS specify-L to allow the linker to find the library and link it to, the runtime linker cannot find this library. If you want to extend the path of the library file during software runtime, then we need to add these 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. /configure previously set the environment variable export LDFLAGS = "-L/var/xxx/lib-L/opt/mysql/lib-Wl, R/var/xxx/lib-Wl, r/opt/mysql/lib ". Note that no space is allowed on both sides of the environment variable equal sign and quotation marks must be added (shell usage ). After configure is executed, Makefile will set this option. This parameter will be used during the link, and the library file search path of the compiled executable program will be extended.

Http://www.cnblogs.com/taskiller/archive/2012/12/14/2817650.html

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.