Embedding Python with Dynamic Loading (win)

S

Simon Steele

Hi,

I'm trying to embed python into my application, and have everything
working fine using the static import lib. However, I don't want my
application to be dependant on python being installed (it's an
optional script interpreter). Therefore I want to be able to
dynamically load python instead (which I believe is possible, but I
can't find any examples for). It seems, however, that the import lib
is imported in python.h using a pragma statement.

1. Is there any suggested way to prevent this import without modifying
python.h?

2. Does anyone have a modified python.h which uses LoadLibrary /
dlopen that they'd be willing to share to save me from writing my own?

3. Has anyone had any success dynamically loading python and using
swig modules in the same process (just to check I'm not insane for
trying this)?

thanks in advance,

Simon.
 
J

Jeff Epler

Simon,
I have heard that vim can use dlopen() (the unix equivalent of
LoadLibrary) to run Python extensions if it's configured that way. You
might want to look at their code.

Jeff
 
M

Michael Geary

Simon said:
I'm trying to embed python into my application, and have
everything working fine using the static import lib.
However, I don't want my application to be dependant on
python being installed (it's an optional script interpreter).
Therefore I want to be able to dynamically load python
instead (which I believe is possible, but I can't find any
examples for). It seems, however, that the import lib is
imported in python.h using a pragma statement.

1. Is there any suggested way to prevent this import
without modifying python.h?

Assuming you're using Visual C++, you could use delay loading, which
essentially converts any imported DLL to use LoadLibrary/GetProcAddress
without requiring any code changes.

http://msdn.microsoft.com/library/d...vcconLinkerSupportForDelayedLoadingOfDLLs.asp

or

http://tinyurl.com/2bmzr

-Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,174
Messages
2,570,940
Members
47,486
Latest member
websterztechnologies01

Latest Threads

Top