|
Boost : |
From: thor.arne.johansen_at_[hidden]
Date: 2002-11-25 14:49:32
Hello,
I'm trying to embedd and extend a C++ application.
I was not able to find any good examples of how to do this. From the small
tidbits of information I found, plus browsing the Boost.Python sources, I
tried the following approach (starting from the "getting_started2" example,
with an added main() + other functions):
use bjam -omylog.txt -n -sTOOLS=msvc
To get a log of what exactly goes on when bjam builds the examples. Looking
at the log it seems we have to make som modifications:
Compile step:
remove -DBOOST_DYNAMIC_LIB
Link step:
remove /DLL
change /out: (file extension should be .exe instead of .pyd)
remove /implib:* (no need for an import lib for an .exe)
Using these modifications to the command lines we can compile and link an
application.
It seems to work fine. I manually call the init function (whatever
init##name() expands to in the BOOST_PYTHON_MODULE macro) sometime after
Py_Initialize() init##name(). I can then instatiate objects of classes
defined in C++ in my embedded python script. (There must be a better way to
initialize the module??). I also suspect the application is now exporting
functions and interfaces, but I'm not too worried about that right now.
I would also like to have access to _instances_ of C++ objects. Ie. the
object has already been instantiated in C++, and contains state. I would
like to use this object in an embedded script.
Are there anyone with ideas, pointers, or examples showing how this can be
done?
Thanx,
-- Thor Arne Johansen Dept. Manager R&D Ibas AS
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk