pybind11 icon indicating copy to clipboard operation
pybind11 copied to clipboard

[BUG]: Errors when compiling numpy-related code on Apple silicon platform

Open XWHtorrentx opened this issue 2 years ago • 1 comments

Required prerequisites

  • [X] Make sure you've read the documentation. Your issue may be addressed there.
  • [X] Search the issue tracker and Discussions to verify that this hasn't already been reported. +1 or comment there if it has.
  • [x] Consider asking first in the Gitter chat room or in a Discussion.

Problem description

Compiler:Clang++

C++ std: 11

Bug Info Undefined symbols for architecture arm64: "_PyBaseObject_Type", referenced from: pybind11::detail::make_object_base_type(_typeobject*) in example-105e26.o "_PyBuffer_Release", referenced from: pybind11::buffer_info::~buffer_info() in example-105e26.o "_PyByteArray_AsString", referenced from: bool pybind11::detail::string_caster<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, false>::load_raw(std::__1::enable_if<std::is_same<char, char>::value, pybind11::handle>::type) in example-105e26.o "_PyByteArray_Size", referenced from: bool pybind11::detail::string_caster<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, false>::load_raw(std::__1::enable_if<std::is_same<char, char>::value, pybind11::handle>::type) in example-105e26.o "_PyByteArray_Type", referenced from: bool pybind11::detail::string_caster<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, false>::load_raw(std::__1::enable_if<std::is_same<char, char>::value, pybind11::handle>::type) in example-105e26.o "_PyBytes_AsString", referenced from: bool pybind11::detail::string_caster<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, false>::load_raw(std::__1::enable_if<std::is_same<char, char>::value, pybind11::handle>::type) in example-105e26.o "_PyBytes_AsStringAndSize", referenced from: pybind11::str::operator std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >() const in example-105e26.o "_PyBytes_Size", referenced from: bool pybind11::detail::string_caster<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, false>::load_raw(std::__1::enable_if<std::is_same<char, char>::value, pybind11::handle>::type) in example-105e26.o "_PyCFunction_Type", referenced from: pybind11::cpp_function::initialize_generic(std::__1::unique_ptr<pybind11::detail::function_record, pybind11::cpp_function::InitializingFunctionRecordDeleter>&&, char const*, std::type_info const* const*, unsigned long) in example-105e26.o "_PyCMethod_New", referenced from: pybind11::cpp_function::initialize_generic(std::__1::unique_ptr<pybind11::detail::function_record, pybind11::cpp_function::InitializingFunctionRecordDeleter>&&, char const*, std::type_info const* const*, unsigned long) in example-105e26.o "_PyCapsule_GetContext", referenced from: pybind11::capsule::capsule(void const*, void ()(void))::'lambda'(_object*)::operator()(_object*) const in example-105e26.o "_PyCapsule_GetName", referenced from: pybind11::detail::internals** pybind11::capsule::get_pointerpybind11::detail::internals*() const in example-105e26.o pybind11::detail::function_record* pybind11::capsule::get_pointerpybind11::detail::function_record() const in example-105e26.o pybind11::capsule::get_name_in_error_scope(_object*) in example-105e26.o "_PyCapsule_GetPointer", referenced from: pybind11::detail::internals** pybind11::capsule::get_pointerpybind11::detail::internals*() const in example-105e26.o pybind11::cpp_function::dispatcher(_object*, _object*, _object*) in example-105e26.o pybind11::detail::function_record* pybind11::capsule::get_pointerpybind11::detail::function_record() const in example-105e26.o pybind11::capsule::capsule(void const*, void ()(void))::'lambda'(_object*)::operator()(_object*) const in example-105e26.o pybind11::detail::npy_api::lookup() in example-105e26.o "_PyCapsule_New", referenced from: pybind11::capsule::capsule(void const*, char const*, void ()(_object)) in example-105e26.o pybind11::capsule::capsule(void const*, void ()(void)) in example-105e26.o "_PyCapsule_SetContext", referenced from: pybind11::capsule::capsule(void const*, void ()(void)) in example-105e26.o "_PyCapsule_SetPointer", referenced from: pybind11::cpp_function::initialize_generic(std::__1::unique_ptr<pybind11::detail::function_record, pybind11::cpp_function::InitializingFunctionRecordDeleter>&&, char const*, std::type_info const* const*, unsigned long) in example-105e26.o "_PyCapsule_Type", referenced from: pybind11::detail::get_internals() in example-105e26.o pybind11::capsule::capsule(pybind11::object&&) in example-105e26.o pybind11::cpp_function::initialize_generic(std::__1::unique_ptr<pybind11::detail::function_record, pybind11::cpp_function::InitializingFunctionRecordDeleter>&&, char const*, std::type_info const* const*, unsigned long) in example-105e26.o "_PyDict_Copy", referenced from: pybind11::cpp_function::dispatcher(_object*, _object*, _object*) in example-105e26.o "_PyDict_DelItemString", referenced from: pybind11::cpp_function::dispatcher(_object*, _object*, _object*) in example-105e26.o "_PyDict_GetItemWithError", referenced from: pybind11::detail::dict_getitemstring(_object*, char const*) in example-105e26.o "_PyDict_New", referenced from: pybind11::cpp_function::dispatcher(_object*, _object*, _object*) in example-105e26.o "_PyDict_Next", referenced from: pybind11::cpp_function::dispatcher(_object*, _object*, _object*) in example-105e26.o "_PyDict_Size", referenced from: pybind11::cpp_function::dispatcher(_object*, _object*, _object*) in example-105e26.o "_PyErr_Clear", referenced from: pybind11::detail::string_caster<std::__1::basic_string<char, std::__1::char_traits, std::1::allocator >, false>::load(pybind11::handle, bool) in example-105e26.o pybind11::detail::type_caster<bool, void>& pybind11::detail::load_type<bool, void>(pybind11::detail::type_caster<bool, void>&, pybind11::handle const&) in example-105e26.o pybind11::module& pybind11::module::def<pybind11::array_t<double, 16> ()(pybind11::array_t<double, 16>, pybind11::array_t<double, 16>), char [21]>(char const, pybind11::array_t<double, 16> (&&)(pybind11::array_t<double, 16>, pybind11::array_t<double, 16>), char const (&) [21]) in example-105e26.o bool pybind11::detail::argument_loader<pybind11::array_t<double, 16>, pybind11::array_t<double, 16> >::load_impl_sequence<0ul, 1ul>(pybind11::detail::function_call&, pybind11::detail::index_sequence<0ul, 1ul>) in example-105e26.o "_PyErr_Fetch", referenced from: pybind11::detail::get_internals() in example-105e26.o pybind11::error_already_set::error_already_set() in example-105e26.o pybind11::error_already_set::m_fetched_error_deleter(pybind11::detail::error_fetch_and_normalize) in example-105e26.o pybind11::error_already_set::what() const in example-105e26.o pybind11::detail::error_fetch_and_normalize::error_fetch_and_normalize(char const*) in example-105e26.o pybind11::raise_from(_object*, char const*) in example-105e26.o pybind11::capsule::capsule(void const*, void ()(void))::'lambda'(_object*)::operator()(_object*) const in example-105e26.o ... "_PyErr_Format", referenced from: _PyInit_test in example-105e26.o _pybind11_meta_call in example-105e26.o "_PyErr_NormalizeException", referenced from: pybind11::detail::error_fetch_and_normalize::error_fetch_and_normalize(char const*) in example-105e26.o pybind11::raise_from(_object*, char const*) in example-105e26.o "PyErr_Occurred", referenced from: pybind11::module::create_extension_module(char const*, char const*, PyModuleDef*) in example-105e26.o pybind11::pybind11_fail(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&) in example-105e26.o pybind11::pybind11_fail(char const*) in example-105e26.o pybind11::detail::translate_exception(std::exception_ptr) in example-105e26.o pybind11::detail::internals** pybind11::capsule::get_pointerpybind11::detail::internals*() const in example-105e26.o pybind11::raise_from(_object*, char const*) in example-105e26.o pybind11::cpp_function::dispatcher(_object*, _object*, _object*) in example-105e26.o ... "_PyErr_Restore", referenced from: pybind11::detail::get_internals() in example-105e26.o pybind11::error_already_set::error_already_set() in example-105e26.o pybind11::error_already_set::m_fetched_error_deleter(pybind11::detail::error_fetch_and_normalize*) in example-105e26.o pybind11::error_already_set::what() const in example-105e26.o pybind11::detail::error_fetch_and_normalize::restore() in example-105e26.o pybind11::raise_from(_object*, char const*) in example-105e26.o pybind11::capsule::capsule(void const*, void ()(void))::'lambda'(_object*)::operator()(_object*) const in example-105e26.o ... "_PyErr_SetString", referenced from: _PyInit_test in example-105e26.o pybind11::cast_error::set_error() const in example-105e26.o pybind11::detail::translate_exception(std::exception_ptr) in example-105e26.o pybind11::type_error::set_error() const in example-105e26.o pybind11::raise_from(_object*, char const*) in example-105e26.o pybind11::cpp_function::dispatcher(_object*, _object*, _object*) in example-105e26.o _pybind11_object_init in example-105e26.o ... "_PyErr_WarnEx", referenced from: pybind11::cpp_function::initialize_generic(std::__1::unique_ptr<pybind11::detail::function_record, pybind11::cpp_function::InitializingFunctionRecordDeleter>&&, char const*, std::type_info const* const*, unsigned long) in example-105e26.o "_PyErr_WriteUnraisable", referenced from: pybind11::capsule::get_name_in_error_scope(_object*) in example-105e26.o "_PyEval_AcquireThread", referenced from: pybind11::gil_scoped_acquire::gil_scoped_acquire() in example-105e26.o "_PyEval_GetBuiltins", referenced from: pybind11::detail::get_internals() in example-105e26.o "_PyEval_SaveThread", referenced from: pybind11::gil_scoped_acquire::~gil_scoped_acquire() in example-105e26.o "_PyExc_FutureWarning", referenced from: pybind11::cpp_function::initialize_generic(std::__1::unique_ptr<pybind11::detail::function_record, pybind11::cpp_function::InitializingFunctionRecordDeleter>&&, char const*, std::type_info const* const*, unsigned long) in example-105e26.o "_PyExc_ImportError", referenced from: _PyInit_test in example-105e26.o "_PyExc_IndexError", referenced from: pybind11::detail::translate_exception(std::exception_ptr) in example-105e26.o "_PyExc_MemoryError", referenced from: pybind11::detail::translate_exception(std::exception_ptr) in example-105e26.o "_PyExc_OverflowError", referenced from: pybind11::detail::translate_exception(std::exception_ptr) in example-105e26.o "_PyExc_RuntimeError", referenced from: pybind11::cast_error::set_error() const in example-105e26.o pybind11::detail::translate_exception(std::exception_ptr) in example-105e26.o "_PyExc_SystemError", referenced from: pybind11::cpp_function::dispatcher(_object*, _object*, _object*) in example-105e26.o "_PyExc_TypeError", referenced from: pybind11::type_error::set_error() const in example-105e26.o _pybind11_meta_call in example-105e26.o pybind11::cpp_function::dispatcher(_object*, _object*, _object*) in example-105e26.o _pybind11_object_init in example-105e26.o "_PyExc_ValueError", referenced from: pybind11::detail::translate_exception(std::exception_ptr) in example-105e26.o pybind11::array_t<double, 16>::raw_array_t(_object*) in example-105e26.o "_PyException_SetCause", referenced from: pybind11::raise_from(_object*, char const*) in example-105e26.o "_PyException_SetContext", referenced from: pybind11::raise_from(_object*, char const*) in example-105e26.o "_PyException_SetTraceback", referenced from: pybind11::raise_from(_object*, char const*) in example-105e26.o "_PyFrame_GetBack", referenced from: pybind11::detail::error_fetch_and_normalize::format_value_and_trace() const in example-105e26.o "_PyFrame_GetCode", referenced from: pybind11::detail::error_fetch_and_normalize::format_value_and_trace() const in example-105e26.o "_PyFrame_GetLineNumber", referenced from: pybind11::detail::error_fetch_and_normalize::format_value_and_trace() const in example-105e26.o "_PyGILState_Check", referenced from: pybind11::object pybind11::detail::object_api<pybind11::detail::accessorpybind11::detail::accessor_policies::str_attr >::operator()<(pybind11::return_value_policy)1, pybind11::str&>(pybind11::str&) const in example-105e26.o pybind11::object pybind11::detail::object_api<pybind11::detail::accessorpybind11::detail::accessor_policies::str_attr >::operator()<(pybind11::return_value_policy)1, pybind11::handle&>(pybind11::handle&) const in example-105e26.o "_PyGILState_Ensure", referenced from: pybind11::detail::get_internals() in example-105e26.o "_PyGILState_GetThisThreadState", referenced from: pybind11::gil_scoped_acquire::gil_scoped_acquire() in example-105e26.o "_PyGILState_Release", referenced from: pybind11::detail::get_internals() in example-105e26.o "_PyImport_ImportModule", referenced from: pybind11::detail::npy_api::lookup() in example-105e26.o "_PyInstanceMethod_New", referenced from: pybind11::cpp_function::initialize_generic(std::__1::unique_ptr<pybind11::detail::function_record, pybind11::cpp_function::InitializingFunctionRecordDeleter>&&, char const*, std::type_info const* const*, unsigned long) in example-105e26.o "_PyInstanceMethod_Type", referenced from: _pybind11_meta_getattro in example-105e26.o pybind11::cpp_function::initialize_generic(std::__1::unique_ptr<pybind11::detail::function_record, pybind11::cpp_function::InitializingFunctionRecordDeleter>&&, char const*, std::type_info const* const*, unsigned long) in example-105e26.o "_PyMem_Calloc", referenced from: pybind11::detail::instance::allocate_layout() in example-105e26.o "_PyMem_Free", referenced from: pybind11::detail::instance::deallocate_layout() in example-105e26.o "PyModule_AddObject", referenced from: pybind11::module::add_object(char const*, pybind11::handle, bool) in example-105e26.o "PyModule_Create2", referenced from: pybind11::module::create_extension_module(char const*, char const*, PyModuleDef*) in example-105e26.o "_PyObject_CallObject", referenced from: pybind11::object pybind11::detail::object_api<pybind11::detail::accessorpybind11::detail::accessor_policies::str_attr >::operator()<(pybind11::return_value_policy)1, pybind11::str&>(pybind11::str&) const in example-105e26.o pybind11::object pybind11::detail::object_api<pybind11::detail::accessorpybind11::detail::accessor_policies::str_attr >::operator()<(pybind11::return_value_policy)1, pybind11::handle&>(pybind11::handle&) const in example-105e26.o "PyObject_ClearWeakRefs", referenced from: pybind11::detail::clear_instance(object*) in example-105e26.o "PyObject_GetAttrString", referenced from: pybind11::detail::accessorpybind11::detail::accessor_policies::str_attr::get_cache() const in example-105e26.o pybind11::module& pybind11::module::def<pybind11::array_t<double, 16> ()(pybind11::array_t<double, 16>, pybind11::array_t<double, 16>), char [21]>(char const, pybind11::array_t<double, 16> (&&)(pybind11::array_t<double, 16>, pybind11::array_t<double, 16>), char const (&) [21]) in example-105e26.o "_PyObject_GetBuffer", referenced from: pybind11::buffer::request(bool) const in example-105e26.o "_PyObject_GetItem", referenced from: pybind11::detail::accessorpybind11::detail::accessor_policies::generic_item::get_cache() const in example-105e26.o "_PyObject_HasAttrString", referenced from: pybind11::cpp_function::initialize_generic(std::__1::unique_ptr<pybind11::detail::function_record, pybind11::cpp_function::InitializingFunctionRecordDeleter>&&, char const, std::type_info const* const*, unsigned long) in example-105e26.o pybind11::module::add_object(char const*, pybind11::handle, bool) in example-105e26.o "_PyObject_IsInstance", referenced from: _pybind11_meta_setattro in example-105e26.o "_PyObject_Repr", referenced from: pybind11::cpp_function::initialize_generic(std::__1::unique_ptr<pybind11::detail::function_record, pybind11::cpp_function::InitializingFunctionRecordDeleter>&&, char const*, std::type_info const* const*, unsigned long) in example-105e26.o pybind11::cpp_function::dispatcher(_object*, _object*, _object*) in example-105e26.o "_PyObject_SetAttrString", referenced from: pybind11::detail::make_static_property_type() in example-105e26.o pybind11::detail::make_default_metaclass() in example-105e26.o pybind11::detail::make_object_base_type(_typeobject*) in example-105e26.o "_PyObject_SetItem", referenced from: pybind11::detail::get_internals() in example-105e26.o "_PyObject_Str", referenced from: pybind11::detail::error_fetch_and_normalize::format_value_and_trace() const in example-105e26.o pybind11::str::str(pybind11::handle) in example-105e26.o pybind11::str::str(pybind11::object&&) in example-105e26.o "_PyProperty_Type", referenced from: pybind11::detail::make_static_property_type() in example-105e26.o _pybind11_static_get in example-105e26.o _pybind11_static_set in example-105e26.o "_PyThreadState_Clear", referenced from: pybind11::gil_scoped_acquire::dec_ref() in example-105e26.o "_PyThreadState_DeleteCurrent", referenced from: pybind11::gil_scoped_acquire::dec_ref() in example-105e26.o "_PyThreadState_Get", referenced from: pybind11::detail::get_internals() in example-105e26.o "_PyThreadState_New", referenced from: pybind11::gil_scoped_acquire::gil_scoped_acquire() in example-105e26.o "_PyThread_tss_alloc", referenced from: pybind11::detail::get_internals() in example-105e26.o pybind11::detail::local_internals::local_internals() in example-105e26.o "_PyThread_tss_create", referenced from: pybind11::detail::get_internals() in example-105e26.o pybind11::detail::local_internals::local_internals() in example-105e26.o "_PyThread_tss_get", referenced from: pybind11::gil_scoped_acquire::gil_scoped_acquire() in example-105e26.o pybind11::detail::loader_life_support::loader_life_support() in example-105e26.o pybind11::detail::loader_life_support::~loader_life_support() in example-105e26.o "_PyThread_tss_set", referenced from: pybind11::detail::get_internals() in example-105e26.o pybind11::gil_scoped_acquire::gil_scoped_acquire() in example-105e26.o pybind11::gil_scoped_acquire::dec_ref() in example-105e26.o pybind11::detail::loader_life_support::loader_life_support() in example-105e26.o pybind11::detail::loader_life_support::~loader_life_support() in example-105e26.o "_PyTuple_GetItem", referenced from: pybind11::detail::accessorpybind11::detail::accessor_policies::tuple_item::get_cache() const in example-105e26.o "_PyTuple_New", referenced from: pybind11::tuple pybind11::make_tuple<(pybind11::return_value_policy)1, pybind11::str&>(pybind11::str&) in example-105e26.o pybind11::cpp_function::dispatcher(_object*, _object*, _object*) in example-105e26.o pybind11::tuple pybind11::make_tuple<(pybind11::return_value_policy)1, pybind11::handle&>(pybind11::handle&) in example-105e26.o "_PyTuple_SetItem", referenced from: pybind11::cpp_function::dispatcher(_object*, _object*, _object*) in example-105e26.o "_PyTuple_Size", referenced from: pybind11::cpp_function::dispatcher(_object*, _object*, _object*) in example-105e26.o "_PyType_IsSubtype", referenced from: bool pybind11::detail::string_caster<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, false>::load_raw(std::__1::enable_if<std::is_same<char, char>::value, pybind11::handle>::type) in example-105e26.o pybind11::cpp_function::initialize_generic(std::__1::unique_ptr<pybind11::detail::function_record, pybind11::cpp_function::InitializingFunctionRecordDeleter>&&, char const*, std::type_info const* const*, unsigned long) in example-105e26.o pybind11::cpp_function::dispatcher(_object*, _object*, object*) in example-105e26.o pybind11::array::array(pybind11::dtype const&, pybind11::detail::any_container, pybind11::detail::any_container, void const*, pybind11::handle) in example-105e26.o pybind11::array_t<double, 16>::check(pybind11::handle) in example-105e26.o "_PyType_Ready", referenced from: pybind11::detail::make_static_property_type() in example-105e26.o pybind11::detail::make_default_metaclass() in example-105e26.o pybind11::detail::make_object_base_type(_typeobject*) in example-105e26.o "_PyType_Type", referenced from: pybind11::detail::error_fetch_and_normalize::error_fetch_and_normalize(char const*) in example-105e26.o pybind11::detail::make_static_property_type() in example-105e26.o pybind11::detail::make_default_metaclass() in example-105e26.o _pybind11_meta_call in example-105e26.o _pybind11_meta_setattro in example-105e26.o _pybind11_meta_getattro in example-105e26.o _pybind11_meta_dealloc in example-105e26.o ... "_PyUnicode_AsUTF8AndSize", referenced from: pybind11::detail::string_caster<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, false>::load(pybind11::handle, bool) in example-105e26.o "_PyUnicode_AsUTF8String", referenced from: pybind11::str::operator std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >() const in example-105e26.o "_PyUnicode_FromString", referenced from: pybind11::detail::get_internals() in example-105e26.o pybind11::detail::make_static_property_type() in example-105e26.o pybind11::detail::make_default_metaclass() in example-105e26.o pybind11::detail::make_object_base_type(_typeobject*) in example-105e26.o pybind11::cpp_function::dispatcher(_object*, _object*, _object*) in example-105e26.o pybind11::detail::dict_getitemstring(_object*, char const*) in example-105e26.o "_PyWeakref_NewRef", referenced from: pybind11::weakref::weakref(pybind11::handle, pybind11::handle) in example-105e26.o "_Py_GetVersion", referenced from: _PyInit_test in example-105e26.o "__PyObject_GetDictPtr", referenced from: pybind11::detail::clear_instance(_object*) in example-105e26.o "__PyThreadState_UncheckedGet", referenced from: pybind11::gil_scoped_acquire::gil_scoped_acquire() in example-105e26.o pybind11::gil_scoped_acquire::dec_ref() in example-105e26.o "__PyType_Lookup", referenced from: _pybind11_meta_setattro in example-105e26.o _pybind11_meta_getattro in example-105e26.o "__Py_Dealloc", referenced from: add_arrays(pybind11::array_t<double, 16>, pybind11::array_t<double, 16>) in example-105e26.o _PyInit_test in example-105e26.o pybind11::detail::get_internals() in example-105e26.o pybind11::detail::error_fetch_and_normalize::error_fetch_and_normalize(char const*) in example-105e26.o pybind11::detail::error_fetch_and_normalize::format_value_and_trace() const in example-105e26.o pybind11::detail::error_fetch_and_normalize::~error_fetch_and_normalize() in example-105e26.o pybind11::detail::type_caster<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, void>& pybind11::detail::load_type<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, void>(pybind11::detail::type_caster<std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, void>&, pybind11::handle const&) in example-105e26.o ... "__Py_FalseStruct", referenced from: pybind11::detail::type_caster<bool, void>& pybind11::detail::load_type<bool, void>(pybind11::detail::type_caster<bool, void>&, pybind11::handle const&) in example-105e26.o "__Py_NoneStruct", referenced from: pybind11::detail::type_caster<bool, void>& pybind11::detail::load_type<bool, void>(pybind11::detail::type_caster<bool, void>&, pybind11::handle const&) in example-105e26.o pybind11::cpp_function::initialize_generic(std::__1::unique_ptr<pybind11::detail::function_record, pybind11::cpp_function::InitializingFunctionRecordDeleter>&&, char const*, std::type_info const* const*, unsigned long) in example-105e26.o void pybind11::cpp_function::initialize<pybind11::detail::all_type_info_get_cache(_typeobject*)::'lambda'(pybind11::handle), void, pybind11::handle>(pybind11::detail::all_type_info_get_cache(_typeobject*)::'lambda'(pybind11::handle)&&, void ()(pybind11::handle))::'lambda'(pybind11::detail::function_call&)::__invoke(pybind11::detail::function_call&) in example-105e26.o pybind11::cpp_function::dispatcher(_object, object*, object*) in example-105e26.o pybind11::module& pybind11::module::def<pybind11::array_t<double, 16> ()(pybind11::array_t<double, 16>, pybind11::array_t<double, 16>), char [21]>(char const, pybind11::array_t<double, 16> (&&)(pybind11::array_t<double, 16>, pybind11::array_t<double, 16>), char const (&) [21]) in example-105e26.o "__Py_NotImplementedStruct", referenced from: pybind11::cpp_function::dispatcher(_object, _object*, _object*) in example-105e26.o "__Py_TrueStruct", referenced from: pybind11::detail::type_caster<bool, void>& pybind11::detail::load_type<bool, void>(pybind11::detail::type_caster<bool, void>&, pybind11::handle const&) in example-105e26.o ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation

Reproducible example code

#include <pybind11/pybind11.h>
#include <pybind11/numpy.h>

namespace py = pybind11;

py::array_t<double> add_arrays(py::array_t<double> input1, py::array_t<double> input2) {
    py::buffer_info buf1 = input1.request(), buf2 = input2.request();

    if (buf1.ndim != 1 || buf2.ndim != 1)
        throw std::runtime_error("Number of dimensions must be one");

    if (buf1.size != buf2.size)
        throw std::runtime_error("Input shapes must match");

    /* No pointer is passed, so NumPy will allocate the buffer */
    auto result = py::array_t<double>(buf1.size);

    py::buffer_info buf3 = result.request();

    double *ptr1 = static_cast<double *>(buf1.ptr);
    double *ptr2 = static_cast<double *>(buf2.ptr);
    double *ptr3 = static_cast<double *>(buf3.ptr);

    for (size_t idx = 0; idx < buf1.shape[0]; idx++)
        ptr3[idx] = ptr1[idx] + ptr2[idx];

    return result;
}

PYBIND11_MODULE(test, m) {
    m.def("add_arrays", &add_arrays, "Add two NumPy arrays");
}

XWHtorrentx avatar Sep 15 '22 10:09 XWHtorrentx

Are you cross compiling to AS or on AS?

henryiii avatar Sep 21 '22 18:09 henryiii

Are you cross compiling to AS or on AS?

I was compiling on apple silicon

XWHtorrentx avatar Sep 29 '22 08:09 XWHtorrentx

Hi @XWHtorrentx, what is your exact used compiler & linker? Can you pls post the CMake output?

Try to remove symbols stripping as the first work-around. I am guessing this is something like: https://github.com/AMReX-Codes/pyamrex/issues/35

ax3l avatar Sep 29 '22 18:09 ax3l