[英]Trouble with cmake when install pybind11
I am trying to get started with pybind11, following the documentation .我正在尝试按照文档开始使用 pybind11。 I have installed pybind11 using pip.
我已经使用 pip 安装了 pybind11。 The location of the directory is:
目录的位置是:
~/anaconda3/lib/python3.6/site-packages/pybind11
The next step is to compile the test cases.下一步是编译测试用例。 According to the documentation, I should run
根据文档,我应该运行
mkdir build
cd build
cmake ..
make check -j 4
However, when running cmake ..
I get the error CMake Error: The source directory "/home/MyUserName/anaconda3/lib/python3.6/site-packages/pybind11" does not appear to contain CMakeLists.txt
.但是,当运行
cmake ..
我收到错误CMake Error: The source directory "/home/MyUserName/anaconda3/lib/python3.6/site-packages/pybind11" does not appear to contain CMakeLists.txt
。 So it seems that I don't have the file CMakeLists.txt
in the pybind11
directory that was created by the pip install.所以看起来我在 pip install 创建的
pybind11
目录中没有文件CMakeLists.txt
。
Any idea about what's gone wrong here?知道这里出了什么问题吗?
When you install pybind11by using pip, you will get only the result and not the source of pybind (the py files, the include files ... ).当您使用 pip 安装 pybind11 时,您将只获得结果而不是 pybind 的来源(py 文件、包含文件...)。
To run the example, you have to checkout the sources git clone --recursive https://github.com/pybind/cmake_example.git
and then run the commands according to the documentation.要运行该示例,您必须签出源
git clone --recursive https://github.com/pybind/cmake_example.git
,然后根据文档运行命令。
I am struggling with the same issue.我正在努力解决同样的问题。 However, I did start to include pybind11 as a submodule.
但是,我确实开始将 pybind11 作为子模块包含在内。 When trying to run "cmake .." I get the following error code:
尝试运行“cmake ..”时,我收到以下错误代码:
CMake Error: The source directory "C:/Users/XXXXX/Documents/GitHub/MT" does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.
(I am working on a Windows machine, Folder is part of GitHub, Hello World program with C++ works.) (我在 Windows 机器上工作,文件夹是 GitHub 的一部分,使用 C++ 的 Hello World 程序可以工作。)
In the long run trying to run the following minimal code example:从长远来看,尝试运行以下最小代码示例:
#include <pybind11>
int add(int i, int j) {
return i + j;
}
PYBIND11_MODULE(example, m) {
m.doc() = "pybind11 example plugin"; // optional module docstring
m.def("add", &add, "A function which adds two numbers");
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.