[C++-sig] Cross module inheritance failing with the Intel compiler on Linux

J. Michael Owen mikeowen at llnl.gov
Thu Mar 11 02:47:13 CET 2004


I'm trying to use the Intel C++ complier (7.0) on Linux with Boost.Python
(latest release, 1.31.0), but running into problems with cross module
inheritance.  At the end of this message I've appended a stripped down example
of the problem in 4 files: A.hh, B.hh, A.cc, and B.cc.  A.hh defines a base
class "Base", while B.hh defines a class "Derived" which inherits publicly from
"Base".  I compile these into two separate modules (A.cc -> A.so, B.cc -> B.so),
and then fire up python and execute the following:

>>> import A
>>> import B

If I build everything with g++ all is fine and I can use the "Derived" class in
python.  However, if I build with Intel's icc (both Boost.Python and this
example code of course) everything compiles, but I get the following run time
error:

>>> import A
>>> import B
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
RuntimeError: extension class wrapper for base class 4Base has not been created yet
>>>

Are other folks successfully using Intel icc with Boost.Python?  Does anyone
have any suggestions how I could correct this problem?

Thanks!

Mike.

************************************ A.hh **************************************
#include <iostream>
class Base {
public:
  Base() { std::cerr << "Base()" << std::endl; }
  virtual ~Base() { std::cerr << "~Base()" << std::endl;}
  virtual void printMessage() const { std::cerr << "Base instance @ " << this << std::endl; }
};

************************************ B.hh **************************************
#include <iostream>
#include "A.hh"
class Derived: public Base {
public:
  Derived(): Base() { std::cerr << "Derived()" << std::endl; }
  virtual ~Derived() { std::cerr << "~Derived()" << std::endl;}
  virtual void printMessage() const { std::cerr << "Derived instance @ " << this << std::endl; }
};

************************************ A.cc **************************************
#include "A.hh"
#include <boost/python.hpp>
using namespace boost::python;
BOOST_PYTHON_MODULE(A) {
  class_<Base>("Base", init<>())
    .def("printMessage", &Base::printMessage)
    ;
}

************************************ B.cc **************************************
#include "B.hh"
#include <boost/python.hpp>
using namespace boost::python;
BOOST_PYTHON_MODULE(B) {
  class_<Derived, bases<Base> >("Derived", init<>());
}

********************************************************************************
-- 
 "Hey...where are the sunflower seeds?" |       J. Michael Owen         
        o_o /                           |          
        (")                             |       Email:  mikeowen at llnl.gov
       \/'\/                            |
____(__(,_,)_______________________________________________________________




More information about the Cplusplus-sig mailing list