如何在Python中调用C++代码?

如何在Python中调用C++代码?

https://github.com/pybind/pybind11

git clone https://github.com/pybind/pybind11.git

将pybind11移动到extern目录下:

mkdir extern mv ./pybind11/ ./extern/

编写CMakeLists.txt:

cmake_minimum_required(VERSION 3.20) project(example) set(PYTHON_EXECUTABLE /home/stzz/miniforge3/envs/pybind11_envs/bin/python) set(PYTHON_INCLU