Reputation: 173
I see many people showing how I can use the Python API in C++ however, it seems I don't have the API or reference already when I include:
#include "Python.h"
or
#include <Python.h>
I had a look at these sites and gives me everything except where I can get this reference:
I had already installed Python 2.7 and I wondered if other downloads from python.org had my answer. I installed IronPython but had no success.
Where can I get this reference?
Upvotes: 2
Views: 2155
Reputation: 6260
It sounds like you're unclear on how your compiler and linker works. #include is a pre-processor instruction which inserts another file into that point in the file which contains the statement. However, your compiler needs to know where to look for the file, so you need to have the folder which contains Python.h either in your IDE's list of include locations (in Visual Studio for example, this can be done either on a per-project basis, or for the whole IDE), or as an environment variable in your OS.
If the library is a header only library, then that is sufficient, as the whole of the library gets inserted into your code, which is then compiled. However, you've indicated that you're getting a LINK error, which means that although it's been able to find the declarations in Python.h, the linker doesn't know where to find the compiled definitions (which are stored in python27_d.lib). So you also need to add the location of that file to your IDE's list of library locations.
Upvotes: 2
Reputation: 1390
You need to install the development package.
On Ubuntu it is python2.7-dev
Upvotes: 0
Reputation: 63200
You can find it \Python27\include\
. So you'll need to set your include directories to have it look there.
Upvotes: 1