Let's take a look at a list of common predefined variables in makefile.
CFLAGS represents an option for the C compiler, cxxflags represents an option for the C + + compiler. These two variables actually cover the two steps of compiling and assembling. Most programs and libraries at compile time the default optimization level is "2" (using the "-o2" option) and with debug symbols to compile, that is, cflags= "-o2-g", cxxflags= $CFLAGS. In fact, "-O2" has enabled the vast majority of security optimization options. On the other hand, since most options can be used for both variables at the same time, only the option to use one of these variables is described at the end. [Reminder] The options listed below are non-default options, you just need to add them as needed.
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.
ldflags: Some of the optimization parameters used by the compiler, such as GCC, or the location of the library files can be specified. 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.
Part of the Content Reference document: http://blog.csdn.net/lidan3959/article/details/8677515
Cflags/cppflags/cxxflags in Makefile Introduction