问题
I apologize if this is a silly question. But I tried to google this and I couldn't find anything to point me in the right direction. I'd just like to understand what I need to do to 'set-up' cdt to 'understand' my python.h include.
the erroneous statement is this:
#include <Python.h>
but I also tried
#include "Python.h"
And CDT responds with an error sign on the side stating:
Multiple markers at this line
- fatal error: Python.h: No such file or
directory
- Unresolved inclusion: <Python.h>
I am using Eclipse CDT Juno on Ubuntu 12.04. Any pointers would be great!
回答1:
please see this path of how to setup the environment in order to use cpython.
- fully detailed tutorial for Linux
- A small github project contains all the relevant files to use on MAC OSx.
- use python-config in order to get the paths to
Python.h
and to the static lib of python, which you should link your code with.
回答2:
Find the path with:
find / -iname python.h
Once you have the path, add it to:
Project > Properties > GCC C++ Compiler > Includes
If needed, add:
python2.7
to:
GCC C++ Linker > Libraries
回答3:
after installing the python-devel
, locate On Terminal(ctrl+shift+t) by locate Python.h
> the result is the file , copy the path and add it to eclipse by the following instructions.
personaly i like to get in the gist of the code so im adding to the compiler includes. but you can add to the linker as well, as mentioned above.
On eclipse :
Project > Properties > C/C++ Build > Settings > ...Compiler(*) > Includes > Include paths (-l)
Directory : paste the path you've located in terminal.
for example/usr/include/python2.7
press OK
see it was added to the list
press OK
.
enjoy
(*)note: if you are compiling c project choose the include under '.. GCC Copmiler' for C++ '..G++ Compiler'
来源:https://stackoverflow.com/questions/15670586/including-python-h-in-c-file-cdt