[C++-sig] "extension class wrapper for base class has not been created yet" error message on Linux for a project that works fine on Windows
Andras Pap
andras.pap at coventor.com
Wed Feb 4 17:46:52 CET 2009
I am creating a base class "Base::Foo" in Foo.dll(so) and expose it in
the FooWrapper.pyd(so) module. Class "Derived::Bar" derives from
Base::Foo and is in the Bar.dll(so) and exposed in the
BarWrapper.pyd(so) module.
On Windows the following works fine:
Python 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import FooWrapper
>>> import BarWrapper
>>> foo = FooWrapper.Foo()
>>> bar = BarWrapper.Bar()
>>> foo.sayHello()
Hi I am Foo!
>>> bar.sayHello()
Hi I am Bar!
>>>
On Linux I get the:
RuntimeError: extension class wrapper for base class Base::Foo has not
been created yet error:
Python 2.4.2 (#1, Jul 2 2008, 10:27:50)
[GCC 3.2.3 20030502 (Red Hat Linux 3.2.3-59)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import FooWrapper
>>> import BarWrapper
Traceback (most recent call last):
File "<stdin>", line 1, in ?
RuntimeError: extension class wrapper for base class Base::Foo has not
been created yet
>>>
Instantiating "foo" before trying to import BarWrapper does not help:
Python 2.4.2 (#1, Jul 2 2008, 10:27:50)
[GCC 3.2.3 20030502 (Red Hat Linux 3.2.3-59)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import FooWrapper
>>> foo = FooWrapper.Foo()
>>> foo.sayHello()
Hi I am Foo!
>>> import BarWrapper
Traceback (most recent call last):
File "<stdin>", line 1, in ?
RuntimeError: extension class wrapper for base class Base::Foo has not
been created yet
>>>
I am hoping that I am missing a simple step, can anyone help what it may be?
Here are: Foo.cpp/h, FooWrapper.cpp Bar.cpp/h and BarWrapper.cpp:
foo.h:
#ifndef BASE_FOO_H
#define BASE_FOO_H
namespace Base
{
class TEST_BASE Foo
{
public:
/// ctor
Foo();
/// dtor
virtual ~Foo();
virtual void sayHello();
};
} // namespace Base
#endif //BASE_FOO_H
foo.cpp:
#include <iostream>
#include "Foo.h"
using namespace Base;
Foo::Foo()
{
};
Foo::~Foo()
{
};
void Foo::sayHello()
{
std::cout << "Hi I am Foo!" << std:: endl;
}
FooWrapper.h:
#include <vector>
#include <string>
#include <boost/python/class.hpp>
#include <boost/python/module.hpp>
#include <Foo.h>
BOOST_PYTHON_MODULE(FooWrapper)
{
using namespace std;
using namespace boost::python;
using namespace Base;
// Python wrapper for MaterialDocument
class_<Foo>("Foo")
.def("sayHello", &Foo::sayHello)
;
}
Bar.h:
#ifndef DERIVED_BAR_H
#define DERIVED_BAR_H
#include "Foo.h"
namespace Derived
{
class TEST_DERIVED Bar : public Base::Foo
{
public:
/// ctor
Bar();
/// dtor
virtual ~Bar();
virtual void sayHello();
};
} // namespace Derived
#endif //DERIVED_BAR_H
Bar.cpp
#include <iostream>
#include "Bar.h"
using namespace Derived;
Bar::Bar() : Base::Foo()
{
};
Bar::~Bar()
{
};
void Bar::sayHello()
{
std::cout << "Hi I am Bar!" << std:: endl;
}
BarWrapper.cpp
#include <vector>
#include <string>
#include <boost/python/class.hpp>
#include <boost/python/module.hpp>
#include <iostream>
#include <string>
#include <Bar.h>
BOOST_PYTHON_MODULE(BarWrapper)
{
using namespace std;
using namespace boost::python;
using namespace Derived;
// Python wrapper for MaterialDocument
class_<Bar, bases<Base::Foo> >("Bar")
.def("sayHello", &Bar::sayHello)
;
}
--
----------------------------------------------
Andras Pap Ph:(617)497-6880x233
Coventor, Inc. Fax: (617)497-6882
apap at coventor.com Cell: (617)512-5768
----------------------------------------------
More information about the Cplusplus-sig
mailing list