Search code examples
pythonc++boostboost-python

Boost Python "cannot open source file 'pyconfig.h'" when importing using "#include <boost\python.hpp>"


I am attempting to use Boost Python for a project. I have downloaded and build version 1.70 on Windows 10, and I am using Visual Studio Code. When attempting to import boost into my c++ project with the line:

#include <boost\python.hpp>

, I receive the following error:

cannot open source file "pyconfig.h" (dependency of "boost\python.hpp")

I have looked into similar issues, and the primary solution I have found was to edit user-config.jam to include the location of my python installation. I have done so, and the line within user-config.jam looks like this:

using python : 3.7 : C:\Users\broke\AppData\Local\Programs\Python\Python37 ;

After adding this line, I rebuilt Boost Python. This did nothing to remedy the issue. I would greatly appreciate help on this matter. Thank you.


Solution

  • you need to make sure the python/include folder is added to your includes. C:\Python\Python37\include for me on windows. You will also need to link the python library.