[Distutils] How to find out the default include path

M.-A. Lemburg mal@lemburg.com
Thu Oct 24 05:21:01 2002


Mats Wichmann wrote:
> At 01:54 PM 10/23/2002 +0200, M.-A. Lemburg wrote:
>  >M.-A. Lemburg wrote:
>  >> Is there a way to find out the default include path
>  >> used by a compiler ? Does distutils have an API for
>  >> this ?
>  >>
>  >> I scanned the code but couldn't find any hint.
>  >
>  >So far I found these defaults:
>  >
>  >Linux:
>  >    libs:    /lib, /usr/lib
>  >    headers: /usr/include
> 
> Depends on what you mean by "default" :-)

What I'm working on is an automatic system for finding 3rd
party libs to link against, e.g. say I have an extension
which links against OpenSSL I want the setup.py to
automatically find the .so and .h files.

It easy to simply look in a few directories, but I found
that I have to be very careful about adding things like
-I/usr/include to the compiler run, because on some systems
this can bomb (the compiler picks up non-compiler compatible
standard C header files, like e.g. stdarg.h).

> For any given Linux system, the linker will search
> libraries in locations built in to the compilation
> system (I think your list is correct there), plus
> whatever's listed in /etc/ld.so.conf.  Sometimes
> assisted or hampered by what's in /etc/ld.so.cache :-{

Does the linker search there too or only the dynamic
one at load time ?

> Headers are searched in /usr/local/include and
> /usr/include, plus a compiler-private directory
> (pathname determined by compiler version and
> host details).
> 
> It's possible, if the compiler indeed is gcc,
> to ask the compiler to tell you the path to
> the "specs" file for that compiler which you can
> then examine to obtain more details than you
> wanted....(ahem, I've actually had to do this,
> please don't ask why).

Thanks,
-- 
Marc-Andre Lemburg
CEO eGenix.com Software GmbH
_______________________________________________________________________
eGenix.com -- Makers of the Python mx Extensions: mxDateTime,mxODBC,...
Python Consulting:                               http://www.egenix.com/
Python Software:                    http://www.egenix.com/files/python/