Question

I am trying to compile a code which uses the Python.h header. In fact it is the lcm library.

Now, I have Python2.7 and Python3.3 installed on my system. The respective header filer are found in /usr/include/python2.7/ and /usr/include/python3.3m/.

The problem is that the code needs the 2.7 version, but gcc always prefers the 3.3 version.

I tried setting ./configure --prefix /bla/bla CPPFLAGS=-I/usr/include/python2.7/ and export C_INCLUDE_PATH=/usr/include/python2.7, none of which worked.

An intermediate workaround is to change the code to #include <python2.7/Python.h> but that makes it unportable, so it will not serve as a fix for the lcm people...

There must be a way!!!

Was it helpful?

Solution

GCC probably prefers the 3.3 version if it's installed as the default that's run when you call 'python' without a version? You could always point that binary at the 2.7 to make it the default on your system..

Looking at the m4 source, seems like you might be able to do the following on one line:

PYTHON=/path/to/python2.7 PYTHON_INCLUDES="-I/usr/include/python2.7" ./configure --prefix /bla/bla

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top