pybind / pybind11

Seamless operability between C++11 and Python
https://pybind11.readthedocs.io/
Other
15.66k stars 2.1k forks source link

[BUG]: cannot compile example/run tests on docs on arm64 macOS #4460

Open sg-s opened 1 year ago

sg-s commented 1 year ago

Required prerequisites

What version (or hash if on master) of pybind11 are you using?

2.10.3

Problem description

I am following along in the getting started section in the docs

when i run,

make check -j 4

I get the following error:

  "__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 embed.cpp.o
  "__Py_NoneStruct", referenced from:
      _pybind11_init_impl_test_cmake_build in embed.cpp.o
      pybind11::detail::type_caster<bool, void>& pybind11::detail::load_type<bool, void>(pybind11::detail::type_caster<bool, void>&, pybind11::handle const&) in embed.cpp.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 embed.cpp.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 embed.cpp.o
      pybind11::cpp_function::dispatcher(_object*, _object*, _object*) in embed.cpp.o
      pybind11::detail::type_caster<char, void>::cast(char const*, pybind11::return_value_policy, pybind11::handle) in embed.cpp.o
  "__Py_NotImplementedStruct", referenced from:
      pybind11::cpp_function::dispatcher(_object*, _object*, _object*) in embed.cpp.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 embed.cpp.o
  "__Py_fopen_obj", referenced from:
      pybind11::object pybind11::eval_file<(pybind11::eval_mode)2>(pybind11::str, pybind11::object, pybind11::object) in embed.cpp.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[7]: *** [test_cmake_build] Error 1
make[6]: *** [CMakeFiles/test_subdirectory_embed.dir/all] Error 2
make[5]: *** [CMakeFiles/check_subdirectory_embed.dir/rule] Error 2
make[4]: *** [check_subdirectory_embed] Error 2

make[3]: *** [tests/test_cmake_build/CMakeFiles/test_build_subdirectory_embed] Error 1
make[2]: *** [tests/test_cmake_build/CMakeFiles/test_build_subdirectory_embed.dir/all] Error 2
make[1]: *** [tests/CMakeFiles/check.dir/rule] Error 2
make: *** [check] Error 2

Reproducible example code

# clone the repo
git clone git@github.com:pybind/pybind11.git

# go to that folder
cd pybind11

# make build folder as in docs and go there
mkdir build
cd build

# this is from the docs here
# https://pybind11.readthedocs.io/en/stable/basics.html
cmake ..
make check -j 4

Is this a regression? Put the last known working version here if it is.

Not a regression

henryiii commented 1 year ago

You are trying to compile against a x86 build of CPython. Where did you get CPython from? I wonder if our search could try to avoid mismatched archs for CPython.

sg-s commented 1 year ago

i see, that's good to know. i'm using a python install from anaconda. can you tell me how to check what my CPython is?