• Advertisement
Sign in to follow this  

Python24.dll and visual studio newbie question

This topic is 4143 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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. ^_^

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement