Reputation: 931
I just want to be able to compile a C++ program with the following line
#include <pybind11/pybind11.h>
I have tried to set the path with cmake:
set(CMAKE_CXX_FLAGS "-march=native -O3 -I /usr/include/python3.9/ -I /home/.local/lib/python3.9/site-packages/pybind11/include/")
Did not work. Direct path to file in CMAKE_CXX_FLAGS leads to file not found.
I tried to add the header path to the bashrc:
$HOME/.local/lib/python3.9/site-packages/pybind11/include
$ pybind11/pybind11.h
bash: pybind11/pybind11.h: No such file or directory
If I path to:
$HOME/.local/lib/python3.9/site-packages/pybind11/include/pybind11
$ pybind11.h
bash: pybind11.h: command not found...
None of that makes the header visible!
This stuff always works when I try to import headers in C++.
The file
$HOME/.local/lib/python3.9/site-packages/pybind11/include/pybind11/pybind11.h
is definitely on the system. I can do this just fine:
#include </home/.local/lib/python3.9/site-packages/pybind11/include/pybind11/pybind11.h>
What is going on?
Upvotes: 0
Views: 1190
Reputation: 931
I could not figure out how to use the installed pybind11[global], so I just created a git repo for my project and added pybind11 as a submodule.
Then in my cmake I added add_subdirectory(extern/pybind11)
as requested by the docs. I think this builds the source in the directory.
Then I had to use target_include_directories(sps INTERFACE extern/pybind11/include)
so that the sources in target sps could use the headers.
Upvotes: 1