4

I am trying to build using ./configure.

I have

  1. Three include directories

    -I/path1/include
    -I/path2/include
    -I/path3/include
    
  2. Two link directories

    -L/path1/lib
    -L/path2/lib
    
  3. Two -l flag options

    -ltensorflow
    -lasan
    
  4. Two compile flags

    -O3
    -g
    

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

Stephen Kitt
  • 434,908
Sap BH
  • 45

2 Answers2

10

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.

Stephen Kitt
  • 434,908
3
export CFLAGS="-I/path1/include -I/path2/include -I/path3/include -O3 -g"
export CXXFLAGS=$CFLAGS
export LDFLAGS="-L/path1/lib -L/path2/lib -ltensorflow -lasan"
./configure && make