Python24.dll and visual studio newbie question

Started by
3 comments, last by signorx 17 years, 6 months ago
I'm working on embedding python interpreter in my c++ App, I use visual c++ express edition. I have installed python 2.4 but when i try this simple code: #include <Python.h> int main(int argc, char *argv[]) { Py_Initialize(); PyRun_SimpleString("from time import time,ctime\n" "print 'Today is',ctime(time())\n"); Py_Finalize(); return 0; } I can't compile it because python.h not found, add python.h to my project but Py_Initialize and all python Api function are not declare, i think I must link python24.dll but I don't know how, Can you help me? Regards
Advertisement
You have setup the include paths for Python?
That would take care of the Python.h (you would just have to include it through #include<Python.h>)

It also automaticly links it for you.

Though, if you redistribute, then don't forget to include Python.dll
Quote:Original post by mldaalder
You have setup the include paths for Python?
That would take care of the Python.h (you would just have to include it through #include<Python.h>)

It also automatically links it for you.

Though, if you redistribute, then don't forget to include Python.dll


Thanks a lot! But another stupid question:
How i can setup the include paths for Python?
Sorry for this noob question but I'm relative new with windows and Gui programming, I always work with Unix console programming and a little with WxPython.

regards

It largely depends on your IDE.

Under VS 2005 Proffesional (that I use) it's under "Tools/Options/Projects and Sollutions/VC++ Directories".

Then change the "Show Directories" to "Include files" and add the directory "<Your Python Path>\include".


Though, what I do is this:
I create a single directory somewhere secure (in my case, called Libraries) and create 2 subdirectories there, called "Includes" and "Libs" (I set these directories as described above).
I put the include files of all my libraries in the "Includes" and their lib (and dll) files in Libs.

In case of Python, I need to have multiple versions of Python installed (maintenance stuff), so I keep it in Python25 (Python 2.5) and Python152 (Python 1.5.2).
In the code, I then include this:
#include<Python25/Python.h>

And it works. ^_^
Quote:Original post by mldaalder
It largely depends on your IDE.

Under VS 2005 Proffesional (that I use) it's under "Tools/Options/Projects and Sollutions/VC++ Directories".

Then change the "Show Directories" to "Include files" and add the directory "<Your Python Path>\include".


Though, what I do is this:
I create a single directory somewhere secure (in my case, called Libraries) and create 2 subdirectories there, called "Includes" and "Libs" (I set these directories as described above).
I put the include files of all my libraries in the "Includes" and their lib (and dll) files in Libs.

In case of Python, I need to have multiple versions of Python installed (maintenance stuff), so I keep it in Python25 (Python 2.5) and Python152 (Python 1.5.2).
In the code, I then include this:
#include<Python25/Python.h>

And it works. ^_^


Thanks a lot! Now always work perfectly... Thanks Thanks Thanks!

regards

This topic is closed to new replies.

Advertisement