-
I have a module defined with nanobind:
I'm trying to wrap an existing TestStruct with nanobind and use it with PyObject_CallObject:
CMake and nanobind are building the NB_MODULE and I'm linking the PyObject_CallObject code against the built shared object. The code trying to run PyObject_CallObject is not being built using the nanobind_add_module (it's part of a bigger application) but it includes the TestStruct definition and the nanobind headers. nb::type consistently returns a null pointer in the handle, which seems to indicate it couldn't find the type. I've included the NB_MODULE definition in the same file as the PyObject_CallObject code, and there is no change in the return for nb::type. Should I be able to look up the python type this way? Do I need to populate the list of python types somehow? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
Careful with reference counting. Use either |
Beta Was this translation helpful? Give feedback.
Ok, this seems resolved by adding
__attribute__ ((visibility("default")))
to the struct definition. Besides hash_code's matching and type_index working to find the type in the internals.type_c2p map, I can now see the type in the symbols of the so produced by the nanobind cmake routines.