How to find out the default include path
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. 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/
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 Windows: libs: $LIB headers: $INCLUDE Are there similar settings or environment variables on other platforms ? 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/
"M.-A. Lemburg" <mal@lemburg.com> writes:
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
Windows: libs: $LIB headers: $INCLUDE
Hm, what do you mean? These are not always set on Windows, depending on how MSVC was installed. You are aware of the function get_msvc_paths() in msvccompiler.py? Thomas
Thomas Heller wrote:
"M.-A. Lemburg" <mal@lemburg.com> writes:
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
Windows: libs: $LIB headers: $INCLUDE
Hm, what do you mean?
I took the Windows environment vars from the the file vcvars32.bat that comes with VC++
These are not always set on Windows, depending on how MSVC was installed.
You are aware of the function get_msvc_paths() in msvccompiler.py?
Not until now :-) What about other Unixes and MacOS ? 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/
On Wed, 23 Oct 2002, 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
/lib is used by the system, python related stuff should never go there, not even look there. Under Linux I would suggest the following defaults: libs: /usr/local/lib, /opt/lib, /usr/lib headers: /usr/local/include, /opt/include, /usr/include If it matters, add also <sys.prefix>/lib, <sys.prefix>/include (some people install Python with --prefix=$HOME, for example). Also, compilers may use their one include/lib directories, e.g. gcc uses <prefix>/lib/gcc-lib/i686-pc-linux-gnu/3.0.4/ <prefix>/include/g++-v3/ Pearu
Pearu Peterson wrote:
On Wed, 23 Oct 2002, 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
/lib is used by the system, python related stuff should never go there, not even look there.
Ok.
Under Linux I would suggest the following defaults:
libs: /usr/local/lib, /opt/lib, /usr/lib headers: /usr/local/include, /opt/include, /usr/include
Thanks.
If it matters, add also <sys.prefix>/lib, <sys.prefix>/include (some people install Python with --prefix=$HOME, for example).
Well, these paths are needed to find 3rd party libs to link against, so I'd suspect that Python dirs are not necessary on the default paths.
Also, compilers may use their one include/lib directories, e.g. gcc uses <prefix>/lib/gcc-lib/i686-pc-linux-gnu/3.0.4/ <prefix>/include/g++-v3/
Right, but again, these probably don't contain the libs I'm looking for in the search for 3rd party libs. Should have mentioned that before: The idea is to try the same lookups as the compiler does per default when you don't pass in any -Ipath options. This is needed for auto configuration since I have to check lib and header versions (and sometimes even for naming conflicts) in these files. Thanks again, -- 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/
On Wed, 23 Oct 2002, M.-A. Lemburg wrote:
Pearu Peterson wrote:
If it matters, add also <sys.prefix>/lib, <sys.prefix>/include (some people install Python with --prefix=$HOME, for example).
Well, these paths are needed to find 3rd party libs to link against, so I'd suspect that Python dirs are not necessary on the default paths.
Actually, people may install also 3rd party libs to $HOME. In fact, sometimes Python itself can be considered as one. I do it consistently when I happen to work on a system where I don't have root permissions and sysadmins are so slow to install anything from the 3rd party. Pearu
Pearu Peterson wrote:
On Wed, 23 Oct 2002, M.-A. Lemburg wrote:
Pearu Peterson wrote:
If it matters, add also <sys.prefix>/lib, <sys.prefix>/include (some people install Python with --prefix=$HOME, for example).
Well, these paths are needed to find 3rd party libs to link against, so I'd suspect that Python dirs are not necessary on the default paths.
Actually, people may install also 3rd party libs to $HOME. In fact, sometimes Python itself can be considered as one.
I do it consistently when I happen to work on a system where I don't have root permissions and sysadmins are so slow to install anything from the 3rd party.
Ok, good argument. I'll add that as well, then. -- 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/
Pearu Peterson wrote:
On Wed, 23 Oct 2002, M.-A. Lemburg wrote:
Under Linux I would suggest the following defaults:
libs: /usr/local/lib, /opt/lib, /usr/lib headers: /usr/local/include, /opt/include, /usr/include
Is /opt/include on the compiler's default include path or not ? Dito for /opt/lib ? BTW, is there a way to query the default search path for header files in GCC ? I have so far only found the default path for libs. 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/
On Wed, 23 Oct 2002, M.-A. Lemburg wrote:
Pearu Peterson wrote:
On Wed, 23 Oct 2002, M.-A. Lemburg wrote:
Under Linux I would suggest the following defaults:
libs: /usr/local/lib, /opt/lib, /usr/lib headers: /usr/local/include, /opt/include, /usr/include
Is /opt/include on the compiler's default include path or not ? Dito for /opt/lib ?
Depends on the compiler. For example, the default prefix for Intel compiler is /opt/intel. Though, /opt is more often used on other unices than on Linux, but still used also on Linux (depends on the background of a local sysadmin).
BTW, is there a way to query the default search path for header files in GCC ? I have so far only found the default path for libs.
In principle, one should let the compiler to take care of its paths. Anyway, the answer depends on the version of the compiler. For example, in the case of gcc-3.1, you can study the output of 'gcc -v'. For earlier versions, 2.95 for instance, you can get the lib path and then extrapolate from that the include path (by ../../../../include/g++-v or something like that). Pearu
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" :-) 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 :-{ 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).
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/
On Thu, 24 Oct 2002, M.-A. Lemburg wrote:
Mats Wichmann wrote:
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.
Have you looked at scipy/scipy_distutils/system_info.py? It does exactly this thing for various 3rd party software like atlas,blas,lapack,X11,fftw,etc. and is meant to be easily extendable. See http://scipy.net/cgi-bin/viewcvsx.cgi/*checkout*/scipy/scipy_distutils/syste...
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 ?
I think /etc/ld.so.conf is looked during the load time, linker never uses it. HTH, Pearu
Pearu Peterson wrote:
On Thu, 24 Oct 2002, M.-A. Lemburg wrote:
Mats Wichmann wrote:
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.
Have you looked at scipy/scipy_distutils/system_info.py? It does exactly this thing for various 3rd party software like atlas,blas,lapack,X11,fftw,etc. and is meant to be easily extendable. See
http://scipy.net/cgi-bin/viewcvsx.cgi/*checkout*/scipy/scipy_distutils/syste...
Interesting. That approach is quite similar to what I'm doing in mxSetup.py for my packages. I've also added a reg. expr. search on the files to work around naming conflicts (e.g. ODBC data drivers tend to all use the same names for names for certain header files), so that I can identify these based on the success of the RE search, e.g. # SAP DB 7.3.0.21 ODBC driver mx_Extension('mx.ODBC.SAPDB.mxODBC', ['mx/ODBC/SAPDB/mxODBC.c', 'mx/ODBC/SAPDB/mxSQLCodes.c'], include_dirs=['mx/ODBC/SAPDB'], define_macros=[('SAPDB', None)], needed_includes=[('sql.h', ['/opt/sapdb/interfaces/odbc/incl'], 'ODBC Core functions')], needed_libraries=[('sqlod', ['/opt/sapdb/interfaces/odbc/lib'], '\[SAP DB\]')], data_files=['mx/ODBC/SAPDB/COPYRIGHT', 'mx/ODBC/SAPDB/LICENSE', 'mx/ODBC/SAPDB/README'], packages=['mx.ODBC.SAPDB'], required=0 ), 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/
In article <3DB7BB47.5040500@lemburg.com>, M.-A. Lemburg <mal@lemburg.com> writes ......
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 ?
I thought that executables could specify a preferred location as well for use at dynamic link time, and then there's also LD_LIBRARY_PATH etc etc, must be at least 10 ways to shoot your own foot. -- Robin Becker
participants (5)
-
M.-A. Lemburg
-
Mats Wichmann
-
Pearu Peterson
-
Robin Becker
-
Thomas Heller