J
Jan Drugowitsch
Hi everyone!
I am trying to access a C++ class which is wrapped in a Python object from
another C++ class which is also wrapped in a Python object. I have used the
following file structure:
AClass.h:
Declaration of AClass
typedef of PyObject containing AClass
AClass.cpp:
Including AClass.h
Implementation of AClass
PyAClass.cpp:
Including AClass.h
Python interface to access AClass
BClass.cpp:
Including AClass.h
Declaration of BClass
Implementation of BClass
Python interface to access BClass
AClass has the methods
unsigned int value() const; // reading private value
void setValue(const unsiged int); // setting private value
BClass has the method
unsigned int value(const AClass* aclass) const; // returning aclass->value()
(remember: just a proof-of-concept)
I'm using DistUtils to compile the libraries. AClass.so links AClass.cpp and
PyAClass.cpp, BClass.so links BClass.cpp and AClass.cpp.
Using AClass in Python works without problems, importing BClass, however,
gives the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ImportError: ./BClass.so: undefined symbol: _ZNK6AClass5valueEv
BClass.so, however, seems to contain that symbol:
% nm BClass.so | grep _ZNK6AClass5valueEv
U _ZNK6AClass5valueEv
Any ideas what can go wrong there?
Any hints are appreciated
Cheers,
Jan
P.S.: I'm sorry if this question has been asked a thousand times. It is very
hard to search for in the archives as 'ImportError' is usually a bug in some
software and no solution is given to resolve it.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQBAS5qJFFp72zZfitwRAsurAKDZ4YIFGYH8h65L0Yq/uKLc5LlvrwCghsHe
z7hLY4/UrpGBgoj1nxA4gXg=
=cukc
-----END PGP SIGNATURE-----
I am trying to access a C++ class which is wrapped in a Python object from
another C++ class which is also wrapped in a Python object. I have used the
following file structure:
AClass.h:
Declaration of AClass
typedef of PyObject containing AClass
AClass.cpp:
Including AClass.h
Implementation of AClass
PyAClass.cpp:
Including AClass.h
Python interface to access AClass
BClass.cpp:
Including AClass.h
Declaration of BClass
Implementation of BClass
Python interface to access BClass
AClass has the methods
unsigned int value() const; // reading private value
void setValue(const unsiged int); // setting private value
BClass has the method
unsigned int value(const AClass* aclass) const; // returning aclass->value()
(remember: just a proof-of-concept)
I'm using DistUtils to compile the libraries. AClass.so links AClass.cpp and
PyAClass.cpp, BClass.so links BClass.cpp and AClass.cpp.
Using AClass in Python works without problems, importing BClass, however,
gives the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ImportError: ./BClass.so: undefined symbol: _ZNK6AClass5valueEv
BClass.so, however, seems to contain that symbol:
% nm BClass.so | grep _ZNK6AClass5valueEv
U _ZNK6AClass5valueEv
Any ideas what can go wrong there?
Any hints are appreciated
Cheers,
Jan
P.S.: I'm sorry if this question has been asked a thousand times. It is very
hard to search for in the archives as 'ImportError' is usually a bug in some
software and no solution is given to resolve it.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQBAS5qJFFp72zZfitwRAsurAKDZ4YIFGYH8h65L0Yq/uKLc5LlvrwCghsHe
z7hLY4/UrpGBgoj1nxA4gXg=
=cukc
-----END PGP SIGNATURE-----