Embedding python into a windows application

Gordon Scott gscott2112 at adelphia.net
Wed Mar 12 16:45:39 CET 2003


I can tell you it does work.  I did that at the last job I was at.
Originally we had embedded
python as a static library into the application.  Unfortunately off the top
of my head I can't
remember what it was that was required.  If you dig through the
documentation about embedding, or
the source itself...there was some kind of define you need to include when
building the static lib like
MFC_NO_COREDLL or something like that.

A side note, we eventually went back to linking the dll to the application
because doing the above
caused some problems, in that when trying to import modules into a script
that relied on other dlls,
those dlls would not load.

"Nathan Field" <ndf at cs.hmc.edu> wrote in message
news:mailman.1047441319.19884.python-list at python.org...
> 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