Reputation: 2543
I am trying to wrap a c++ class in Python using swig. I compiled the class and generated .o
file and also the wrap file using swig but now when I try to create a library from the files I get the following error.
$g++ -lpython -dynamiclib vertex.o vertex_wrap.o -o _vertex.so
Undefined symbols for architecture x86_64:
"Cell::removeVertex(Vertex*)", referenced from:
Vertex::kill(Vertex*) in vertex.o
Vertex::~Vertex() in vertex.o
Vertex::~Vertex() in vertex.o
"Cell::addVertex(Vertex*)", referenced from:
Vertex::make(Cell*) in vertex.o
Vertex::Vertex(Cell*) in vertex.o
Vertex::Vertex(Cell*) in vertex.o
ld: symbol(s) not found for architecture x86_64
Upvotes: 2
Views: 714
Reputation: 3043
Vertex
makes calls to a Cell
(probably, a Vertex
is typically contained in a Cell
), namely to Cell::removeVertex(Vertex*)
and Cell::addVertex(Vertex*)
. These functions must be defined in some other source file (perhaps cell.cpp
, just guessing).
So you need to compile the source file cell.cpp
and link cell.o
as well (and perhaps other source files if there are more dependencies)
This has nothing to do with SWIG or wrapping for python by the way.
Upvotes: 1