I am trying to use boost library on Python. In C++ I include boost\python.hpp but it says it cannot open pyconfig.h. How should I do that? I have a Mac with Parallels installed and my C++ code is in Visual Studio on Parallels. I installed homebrew and boost from the terminal, I already had boost on the Parallels side which I have used different times in C++. In short, I did a mess. How can I fix this? Thanks!!
Asked
Active
Viewed 153 times
1 Answers
0
You need to find pyconfig.h
on your machine, then add its directory to your build like -I/some/path
. Often it will be in a directory called python3.7 or whatever version you have.

John Zwinck
- 239,568
- 38
- 324
- 436
-
Hi, thanks I found it. Now I am modifying the path of the files included by waterfall from pyconfig.h and so on. I am stuck with unistd.h. Python.h includes it but I cannot find it. – Marco Di Bartolo Feb 15 '20 at 11:29
-
`unistd.h` is a file for POSIX systems like Linux, it may not exist on Windows unless you do something to install a POSIX subsystem there. See: https://stackoverflow.com/questions/341817/is-there-a-replacement-for-unistd-h-for-windows-visual-c But I guess more generally you should look for some instructions on how to set up the Python C API in your IDE, rather than bashing through it yourself. – John Zwinck Feb 15 '20 at 11:35
-
I am using Python Launcher and IDLE on my Mac, any advice ? – Marco Di Bartolo Feb 15 '20 at 11:43
-
Here's a question about Boost Python on Mac (without Parallels): https://stackoverflow.com/questions/28571611/boost-python-hello-world-on-mac-os-x – John Zwinck Feb 15 '20 at 11:51
-
I am stuck with include
is there a way to avoid this command? Can't I just use boost on python without C++? – Marco Di Bartolo Feb 15 '20 at 18:31 -
@MarcoDiBartolo: What does "Boost on Python without C++" mean?? Boost is a C++ library for C++ developers. Maybe you should start from the very beginning and tell us what you're trying to build. Are you even trying to write C++ code that talks to the Python interpreter? – John Zwinck Feb 16 '20 at 02:04
-
I want to use boost random number generators on python. I already have C++ codes that do what I want to do on python, so, if as you said boost is strictly C++, I need to use boost/python.h. I have been trying by modifying the paths of the files or moving them into boost but the file that gives me problems is cdefs.h, which gives me a preprocessor error – Marco Di Bartolo Feb 16 '20 at 08:48
-
Which specific Boost RNG do you want to be able to invoke from Python? And can you explain a little why Python's own RNG offerings, or those in NumPy, are not sufficient for your use case? – John Zwinck Feb 16 '20 at 08:53
-
They are! I just wanted to take the chance to learn how to make C++ talking to Python – Marco Di Bartolo Feb 16 '20 at 09:06