Pybind11: undefined symbol: _ZN5pynns7BFQueryD1Ev

Created on 13 Nov 2017  路  5Comments  路  Source: pybind/pybind11

I'm making a pacckage called pynns, and I'm getting the following error

>>> import pynns    
Traceback (most recent call last):      
  File "<stdin>", line 1, in <module>   
ImportError: /home/andrey/Programs/conda/lib/python3.6/site-packages/pynns.cpython-36m-x86_64-linux-gnu.so: undefined symbol: _ZN5pynns7BFQueryD1Ev
>>>  

The project has only one class BFQuery I am exporting it as follows:

void init_bfquery(pybind11::module& m)
{
    pybind11::class_<pynns::BFQuery>(m, "BFQuery")
        .def(pybind11::init<>())
        .def("store_data", &pynns::BFQuery::store_data);
}

I'm using the pybind example package:
https://github.com/pybind/python_example

The init_bfquery function is being called inside an auxiliary filemodule.cc

#include <pybind11/pybind11.h>
#include "BFQuery.h"

namespace py = pybind11;


PYBIND11_MODULE(pynns, m) 
{

    init_bfquery(m);


#ifdef VERSION_INFO
    m.attr("__version__") = VERSION_INFO;
#else
    m.attr("__version__") = "dev";
#endif
}

You can see my package on this repository:
https://github.com/AndreyGFranca/pynns

To compile it just type
pip install pynns

Most helpful comment

Where is your destructor defined? Just replace the ; with {} or = default; for now in the header.

That fixes it for me.

PS:
Check the meaning of that message:

c++filt __ZN5pynns7BFQueryD1Ev

Output:

pynns::BFQuery::~BFQuery()

All 5 comments

Shouldn't the name be:

PYBIND11_MODULE(_pynns, m)

?

Anyway, it doesn't seem to be linking to pynns::BFQuery::store_data. Try

pip install --user -v .

For a bit more info. I can't really see where you are building and linking to the pynns::BFQuery class.

Sorry @henryiii , I commited the last version now. Take another look please

Where is your destructor defined? Just replace the ; with {} or = default; for now in the header.

That fixes it for me.

PS:
Check the meaning of that message:

c++filt __ZN5pynns7BFQueryD1Ev

Output:

pynns::BFQuery::~BFQuery()

Works fine!

Thanks @henryiii

@henryiii thanks a lot!!!

take care of your destructor!! yeap!

Was this page helpful?
0 / 5 - 0 ratings