Embedding python into a windows application
Nathan Field
ndf at cs.hmc.edu
Tue Mar 11 22:53:52 EST 2003
I'm having some trouble embedding python into an application, specifically
when I call PyRun_SimpleFile my program segv's. I've found references to
the multithreaded-dll vs. multithreaded stdlib issue with MSVC++, and this
is indeed the problem that I have. As an experiment I rebuilt my app with
/MD and it worked. Unfortunatly this isn't really an option for me for
several reasons see the end of the email).
What I'd like to do is rebuild python with the /MT option instead of /MD.
Unfortunatly this doesn't seem to work, and it continues to crash the same
way as before.
Here's how I tried to do a multithread build (rather than multithread
dll):
Open MSVC++ v6.0 on Python-2.2.2/PCbuild/pcbuild.dsw
Build->Set Active Configuration
Select pythoncore - Release
Project->Settings dialog
C/C++ tab, select Code Generation from pulldown
Select Multithreaded from "Use run-time library:" pulldown
Hit ok in dialog
Set active project to pythoncore
Build->python22.lib
I then link my application against the resulting python22.lib file, and it
dies on the call to PyRun_SimpleFile. Does python work in /MT mode? Am I
doing something wrong when using MSVC++?
nathan
The reasons I can't use /MD:
1. We link against a number of third party libraries that require /MT. I
can hack our build system to avoid linking them in, but eventually I'm
probably going to need them so that's not a solution.
2. We use our own compiler as well as MSVC++, and our own compiler hasn't
been tested/may not support a /MD build.
3. Our build system is very complicated and it would take several days to
rework it. I'd prefer to avoid that if possible.
------------
Nathan Field Root is not something to be shared with strangers.
"There is no reason to eat excessive amounts of junk food, nor go more
than once a week to McDonald's."
-- Ad placed by McDonald's in a popular french magazine
(Femme Actuelle)
More information about the Python-list
mailing list