3

in this thread

https://unix.stackexchange.com/questions/149359/what-is-the-correct-syntax-to-add-cflags-and-ldflags-to-configure

someone says that CFLAGS and LDFLAGS do not work with every configure script. Why? I would like to have more explanation about this, not just the statement ;) Under which circumstances does that work and under which doesn't it? What are the causes?

He (the accepted answer) also mentions that you should use CPATH and LIBRARY_PATH instead. What is the difference between CFLAGS and CPATH? Similarly what is the difference between LDFLAGS and LIBRARY_PATH?

Last question: When I use LDFLAGS = whatever, don't I override previous LDFLAGS definitions that might have been made by the developer himself? Shouldn't the syntax rather be something like ./configure LDFLAGS+=/myPath ?

Community
  • 1
  • 1
user3182532
  • 1,097
  • 5
  • 22
  • 37

1 Answers1

4

CFLAGS/LDFLAGS used by ./configure, CPATH/LIBRARY_PATH used by GCC/MinGW compiler/linker. If ./configure is written good, it firstly get CFLAGS/LDFLAGS from environment before appending any paths to it and calling compiler/linker. In that case, you can use

CFLAGS="-I/usr/local/include" LDFLAGS="-L/usr/local/lib" ./configure

Modern ./configures can accept CFLAGS/LDFLAGS as parameters

./configure CFLAGS="-I/usr/local/include" LDFLAGS="-L/usr/local/lib"

but if ./configure is poor or old, only CPATH/LIBRARY_PATH can help

CPATH=/usr/local/include LIBRARY_PATH=/usr/local/lib ./configure
CPATH=/usr/local/include LIBRARY_PATH=/usr/local/lib make

Altenatives to CPATH/LIBRARY_PATH for Microsoft Visual C++ Compiler is INCLUDE/LIB.

galeksandrp
  • 766
  • 8
  • 17