0

I try to include Python.h for a c++ project. I am on ubuntu 18.04, I installed python3-dev (as I have python3.6 on my system) and everything looks good, I can even locate the Python.h as shown in the image below. But cmake still complains it cannot find Python.h. Did I miss anything? I know I can use -I to pass the directory to gcc, but is it suppose to work right way after I have python3-dev installed and the header shows up under usr/include?

enter image description here

shelper
  • 10,053
  • 8
  • 41
  • 67
  • To find something freshly installed with `locate`, `updatedb` has to be run. – Klaus D. Sep 18 '20 at 02:10
  • @KlausD. interestingly, my `locate updatedb` output does not list `usr/include` – shelper Sep 18 '20 at 02:12
  • Did you literally run `locate updatedb`? – Klaus D. Sep 18 '20 at 02:13
  • yes, and not only that, i found i cannot locate any header file in `/usr/include`, basically the path cannot be found by locate or gcc by default – shelper Sep 18 '20 at 02:15
  • Note the space and comma! `updatedb` is a tool that updates the database for `locate`, without running it the search happens on old information. Usually it is run by cron periodically. – Klaus D. Sep 18 '20 at 02:18
  • see my update in the post with output for updatedb – shelper Sep 18 '20 at 02:20
  • You should read more carefully! – Klaus D. Sep 18 '20 at 02:22
  • sorry about that, after running `sudo updatedb` now i can locate the `Python.h` but gcc still cannot find it... – shelper Sep 18 '20 at 02:35
  • Just to add a bit of clarification - typically Python.h isn't added to the include path. This is so that you can have multiple versions of Python installed and they won't conflict. If you compile you an extension with setup.py then the version of Python you use will set it up automatically. Otherwise your best option is to call `gcc args $(python3-config --includes)` as described by [this answer](https://stackoverflow.com/a/56508166/4657412) – DavidW Sep 20 '20 at 20:25

0 Answers0