I am trying to build using ./configure.

I have

  1. Three include directories

  2. Two link directories

  3. Two -l flag options

  4. Two compile flags


How can I put all these flags effectively as options in ./configure?


The canonical way to do this is to provide values for various variables in the ./configure invocation:

./configure CPPFLAGS="-I/path1/include -I/path2/include -I/path3/include" \
            CFLAGS="-O3 -g" \
            LDFLAGS="-L/path1/lib -L/path2/lib" \
            LIBS="-ltensorflow -lasan"

If the C++ compiler is used, specify CXXFLAGS instead of (or in addition to) CFLAGS.

These variables can also be set in the environment, but recommended practice is to specify them as command-line arguments so that their values will be stored for re-use. See Forcing overrides when configuring a compile (e.g. CXXFLAGS, etc.) for details.

Note that in most cases it would be unusual to specify that many paths as flags; instead, I would expect to find --with options to tell the configure script where to find various dependencies. For example, --with-tensorflow=/path/to/tensorflow which would then result in the appropriate -I and -L flags being set. Run

./configure --help

to see what options are available.

  • I do have a small doubt, does the order in which I put the flags have to be maintained or can I put it in any order, like LIBS first and then LDFLAGS?
    – Sap BH
    Sep 17 at 15:36
  • 1
    The order doesn’t matter. Sep 17 at 15:54
export CFLAGS="-I/path1/include -I/path2/include -I/path3/include -O3 -g"
export LDFLAGS="-L/path1/lib -L/path2/lib -ltensorflow -lasan"
./configure && make

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.