[Tutor] environment settings

D-Man dsh8290@rit.edu
Mon, 9 Jul 2001 21:23:50 -0400


On Mon, Jul 09, 2001 at 02:41:54PM -0700, Robin Kuruvila wrote:
| hello,
| I am using Red Hat Linux 7.0 and use Python2.1 and use gcc 2.95 for
| compilation. I 've included the test programs and the associated make file.
| When run 'gcc hello.c' i get an error saying 'Python.h: No such file or
| directory'
| tried 'gcc -I /usr/include/python2.1/Python.h hello.c' get an error saying
| 'Python.h: No such file or directory'
| 
| I could eliminate the error by hardcoding the header file path within the
| program <python2.1/Python.h> as shown in the example. When i do this i get

This will work because /usr/include is part of the default search
path.

| bunch of linker issues, when compiling.

You need to tell the linker what libraries you want to link to.  You
might have to tell it where the .so is, if it isn't in the default
search path.  I think it should be in /usr/lib which is in the default
search path.  If I assume that the library is "libpython.so" then you
want the following gcc command line :

    gcc -I /usr/include/python2.1 -lpython hello.c

HTH,
-D