"specs" related problems

Mumit Khan khan@xraylith.wisc.edu
Sat Dec 26 12:56:00 GMT 1998

Corinna Vinschen <corinna.vinschen@cityweb.de> writes:
> If you wish to set the default include paths, you may change
> the *cpp line, e.g, to add /usr/local/include in case of cygwin,
> but not for mingw:
> original:
> ---------
> *cpp:
> -remap %(cpp_cpu) %{posix:-D_POSIX_SOURCE} %{!mno-cygwin:-D__CYGWIN32__ -D__C
> YGWIN__} %{mno-cygwin:-iwithprefixbefore include/mingw32 -D__MINGW32__=0.2}
> /usr/local/include added:
> -------------------------
> *cpp:
> -remap %(cpp_cpu) %{posix:-D_POSIX_SOURCE} %{!mno-cygwin:-D__CYGWIN32__ -D__C
> YGWIN__ -I/usr/local/include} %{mno-cygwin:-iwithprefixbefore include/mingw32
>  -D__MINGW32__=0.2}

I recommend not using `-I <path>' in specs file since that makes it hard
to override include paths from command line (which should always take

GNU CPP has the concept of "main" and "second" include paths, and more
often than not, you want to add a path to the beginning of the *second*
include path (eg., /usr/local etc). There is also the concept of "system"
include path.

Here're some of the useful ones from CPP info pages (there are web sites
out there with CPP info pages in html format):

  `-include FILE'
       Process FILE as input, and include all the resulting output,
       before processing the regular input file.

  `-idirafter DIR'
       Add the directory DIR to the second include path.  The directories
       on the second include path are searched when a header file is not
       found in any of the directories in the main include path (the one
       that `-I' adds to).

  `-iprefix PREFIX'
       Specify PREFIX as the prefix for subsequent `-iwithprefix' options.

  `-iwithprefix DIR'
       Add a directory to the second include path.  The directory's name
       is made by concatenating PREFIX and DIR, where PREFIX was
       specified previously with `-iprefix'.

  `-isystem DIR'
       Add a directory to the beginning of the second include path,
     marking it as a system directory, so that it gets the same special
     treatment as is applied to the standard system directories.

You probably want `-idirafter', so that you can override that from the
command line. Unfortunately, these options are rather obtuse and confusing
(I've used these for years, and still get confused).

Unfortunately, there are no such convenient ways to handle library paths,
and you might have to do what Corinna suggests (by adding a -L<path> to
the specs file). I however find it much more convenient to do these via
Makefiles to avoid confusion as to what paths get searched before what.

To add to the confusion, there's also the -B<prefix> option that can be
used to control both the library and system-include search paths. Argh.


For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

More information about the Cygwin mailing list