[C++-sig] Boost.Python embedded doubt
ericjardim at gmail.com
Wed Aug 31 16:31:29 CEST 2005
For QtDesigner integration, I need to embedded Python extended classes
exposed back to C++. So I started with the tutorial and the
Boost.Pythontest example. The test is ok.
Then I changed the example to my needs, and tryed to load the Qt module. The
program compile and run, but output:
Traceback (most recent call last):
File "<string>", line 1, in ?
File "/u/cwd7/devel/boost/python-qt4-0.0.3rc1/Qt/__init__.py", line 8, in ?
undefined symbol: _Py_NoneStruct
This error happens inside the PyRun_String function. I have commented the
line of the "ld" module import, and it complain about another symbol. It
does not look like a "dl" problem, but a linking problem.
Reading the tutorial,
it says: "To be able to use embedding in your programs, they have to be
linked to both Boost.Python's and Python's static link library."
Is it really necessary to both the libs be static? I then (curiously) tried
to link with the boost_python library dynamically and it complained about
another (thrid Py~) symbol.
I am building this app with Qt "qmake". I do not use bjam, because I need
specific precompiling for Qt (easyly done by qmake). But this should not be
so complex, shoud it? I am just using simple:
>>> -L/path/to/python/lib/python2.3/config -lpython2.3 -L/path/to/boost/lib
Am I missing something? Do I have to do anything else?
The code I am trying is:
> using namespace boost::python;
> object main_module((
> object main_namespace = main_module.attr("__dict__");
> // Define the derived class in Python.
> // (You'll normally want to put this in a .py file.)
> python::handle<> result(
> "import Qt\n"
> "from Qt.Gui import QPushButton\n"
> "print QPushButton\n",
> Py_file_input, main_namespace.ptr(), main_namespace.ptr())
> // Result is not needed
I also call PyInitialize first.
Thanks for any help,
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Cplusplus-sig