# pybind11_study **Repository Path**: whu-dft/pybind11_study ## Basic Information - **Project Name**: pybind11_study - **Description**: Repository that store the learning process of pybind11 - **Primary Language**: C++ - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2019-07-03 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # pybind11_study #### Description Repository that store the learning process of pybind11 #### Software Architecture Software architecture description #### Installation 1. xxxx 2. xxxx 3. xxxx #### Instructions 1. xxxx 2. xxxx 3. xxxx #### Contribution 1. Fork the repository 2. Create Feat_xxx branch 3. Commit your code 4. Create Pull Request ### FAQ #### Q1. 采用CMake编译pybind11文件,报错"Unknown CMake command "pybind11_add_module"". 其中CMakeFile.txt内容如下: ```cmake cmake_minimum_required(VERSION 3.0) project(cmake_example) add_subdirectory(/home/fdd/Github/pybind11) pybind11_add_module(cmake_example example.cpp) ``` pybind11_add_module是pybind11模块自带的CMake命令,add_subdirectory需要将pybind11的路径包含进去, 但是这样还不够。CMake编译命令要求pybind11的目录为当前CMakefile的子目录。错误输出信息中提示: ```bash add_subdirectory not given a binary directory but the given source directory "/home/fdd/Github/pybind11" is not a subdirectory of "/home/fdd/Git_study/pybind11_study/step2_cls_wrap". ``` 因此,我们需要对pybind11的项目目录做一个软连接是满足pybind11的CMake编译规则。 ```bash ln -s /home/fdd/Github/pybind11 pybind11 ``` CMakeFile内容修改为: ```cmake cmake_minimum_required(VERSION 3.0) project(cmake_example) add_subdirectory(pybind11) pybind11_add_module(cmake_example example.cpp) ``` 因此在pybind11的编译项目中,都建议将pybind11的项目做软链接,然后通过在CMakeFile.txt中添加 add_subdirectory(pybind11)来实现pybind11的编译。