I am working with Boost/bjam, trying to create a Python wrapper over some C++ code. I am getting this error message from my wrapper:
wrapper.cpp(1): fatal error C1083: Cannot open include file: 'boost/python.hpp': No such file or directory
This is still a problem despite the fact that I added my boost root directory to every conceivable include path I could find in Visual Studio (include directories, external include directories, additional include directories, etc).
I have two questions:
1. Inside Visual Studio, I must create a .sln project and add my .cpp files to this project. Only then can I configure my include directories through Debug > Debug Properties. But the Boost documentation makes no mention of any of this VS stuff, so why do I need to do this before I can configure the include directories for my .cpp code?
2. How can I add include paths outside of Visual Studio, in Powershell or the Anaconda prompt for example? I found no mention of this online, as most people are running Boost/bjam from within VS.
If I have left any details out, let me know and I'll be happy to provide them.
1) boost does not go into the details of what you need to do for every possible tool. visual studio is 5 or 6 of the 30 - 50 tools you could be using. Visual requires you to do this, and there may be more than one way to set it up in VS. In vs, project, properties, c/c++, general, and additional include directories setting should be sufficient.
2) windows path is configured at the computer (rt click) properties -> adv system settings -> environment variables button -> path
you can set it up temp inside cmd with a path command but it will be forgotten after you close that window and it won't be universal, its just inside the one window.
and this one I do not know... it may be important to add the .hpp files to the visual project. This seems likely for any templates etc... but even for basic .h files I add them to the project same as cpp files.
-- boost used to have a ready-to-go compiled library you could just download and use without all the junk to build it. They probably still do.
1. Inside Visual Studio, I must create a .sln project and add my .cpp files to this project. Only then can I configure my include directories through Debug > Debug Properties. But the Boost documentation makes no mention of any of this VS stuff, so why do I need to do this before I can configure the include directories for my .cpp code?
Debug > Debug Properties is not the correct place to specify the location of your Boost headers. You should go to Project > Properties > VC++ Directories. Click on the down arrow on the right, then Edit. Use the dialog that appears to add additional directories to be searched when compiling your project.
Debug > Debug properties is appropriate when you're using a precompiled library and want to see the headers when you're debugging, but don't need the headers in order to compile.
2. How can I add include paths outside of Visual Studio, in Powershell or the Anaconda prompt for example? I found no mention of this online, as most people are running Boost/bjam from within VS.
You should have a INCLUDE environment variable (if not you can add it). In addition to the VC++ include directories mentioned above, VS will also search any directories listed in this environment variable.
There is a somewhat convoluted not-for-a-beginner way to add the Boost library's location to your VS defaults so each new project/solution will find the headers as if Boost were a part of the VS libraries.
I thought this only worked for executable files, not header files.
Maybe. I don't have mine set up for a bunch of paths, I have it set up in the IDE per project. Its a little more annoying but that way you can have multiple versions of something if needed, to debug or compare etc.
you can hack on the 'include' path mentioned from the same place I gave, though.
> You should go to Project > Properties > VC++ Directories. Click on the down arrow on the right, then Edit. Use the dialog that appears to add additional directories to be searched when compiling your project.
I tried this and VS still cannot find the header files. I even added every header file I needed to the project in the Solution Explorer, and it still cannot find them.
One thing I noticed is that "boost/python.hpp" works but <boost/python.hpp> does not. But the former requires me to have moved the boost header folder directly into my VS project folder, and then edit all the other include paths that are defined with angle brackets in those headers. I don't want to do this, as it would obviously be fairly time consuming.
It is possible that you did not set Additional Include Directories in each and every project in QuantLib, which has many projects. You can use the Property Manager (View -> Other Windows -> Property Manager) to add the correct Boost include path to all of the projects at once. https://www.peryourhealth.live/