-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
I checked if similar question has already been answered in the FAQ. The short answer is YES. However, I tried to follow the solution and it did not work. I have been trying to fix this for a week now and I am forced to ask it here.
Issue description
//////////////////////////////////////
Recently, I have been trying to get pybind11 working on my Windows computer. The pybind11 works on my mac OS X without any errors. However, on Windows I receive this error.
C:\Users\Juha.CLion2016.2\system\cygwin_cmake\bin\cmake.exe --build C:\Users\Juha.CLion2016.2\system\cmake\generated\Test-9f0d7c2a\9f0d7c2a\Debug --target Test -- -j 4
Scanning dependencies of target Test
[ 50%] Building CXX object CMakeFiles/Test.dir/main.cpp.o
/cygdrive/c/Users/Juha/Desktop/C++/Test/main.cpp:2:31: fatal error: pybind11/pybind11.h: No such file or directory
compilation terminated.
make[3]: *** [CMakeFiles/Test.dir/build.make:63: CMakeFiles/Test.dir/main.cpp.o] Error 1
make[2]: *** [CMakeFiles/Makefile2:68: CMakeFiles/Test.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:80: CMakeFiles/Test.dir/rule] Error 2
make: *** [Makefile:118: Test] Error 2
Tried solution
//////////////////////////////////////
I tried to make sure that the file pybind11.h could be found by CLion. So I used Windows search to locate pybind11. It turns out that pip install installed pybind11 in the following places:
- C:\Users\Juha\Documents\R\win-library\3.2\Rcpp\include\Rcpp\pybind11
- C:\Users\Juha\Anaconda2\include\pybind11
- C:\Users\Juha\Anaconda2\Library\lib\pybind11
- C:\Users\Juha\Anaconda2\Lib\pybind11
Each folder have the following files:
- __ init __.py
- __ init __.pyc
- _version.py
- _version.pyc
- attr.h
- cast.h
- chrono.h
- complex.h
- descr.h
- eigen.h
- eval.h
- functional.h
- numpy.h
- operators.h
- options.h
16. pybind11.h - pytypes.h
- stl.h
- stl_bind.h
- typeid.h
In each __ init __.py I hardcoded the path pointing to the folder where pybind11.h is located. So for each __ init __.py I hardcoded unique path pointing to the four different folders including pybind11.h. This did not solve the problem. I am clueless.
Reproducible example code
//////////////////////////////////////
In my project folder I have the following files:
- CMakeLists.txt
- main.cpp
CMakeLists.txt
cmake_minimum_required(VERSION 3.6)
project(Test)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(SOURCE_FILES main.cpp)
add_executable(Test ${SOURCE_FILES})
main.cpp
#include <iostream>
#include "pybind11/pybind11.h"
int main() {
std::cout << "Hello, World!" << std::endl;
return 0;
}