Boost Library cannot get to work in C++, Include directories not working - c++

I recently tried to install boost libraries in C++ 14, and I added it's include paths like:
Solution Explorer > Project Name > Property Pages > VC++ Directories > "C:\Program Files (x86)\Microsoft Visual Studio 14.0\boost\boost"
I tried to compile after adding this:
#include <boost\variant.hpp>
In Error List window, I can see E1696 - cannot open source file "boost\variant.hpp" and I can't compile like before.
Then I tried with adding a backslash like "C:\Program Files (x86)\Microsoft Visual Studio 14.0\boost\boost\", still didn't work.
I also read this post and explicitly specified it's directory, but even didn't work.
Again, I read this post and did exactly same what is in given answer (as I already built project several times) , but still no success.
However, if I include a library like:
#include "C:\Program Files (x86)\Microsoft Visual Studio 14.0\boost\boost\variant.hpp"
Now compiler recognizes it, but now I can see more than 100 errors in Error List window, those errors are pointed to header files of boost libraries, not in my project file which has variant.hpp included.
All those errors are E1696 - cannot open source file "boost\<libraryname.hpp>" or E1696 - cannot open source file "boost\<subdirs>\<some other files included in libraryname.hpp>"
So, if I remove the line #include "C:\Program Files (x86)\Microsoft Visual Studio 14.0\boost\boost\variant.hpp" from my project's header file, all errors disappear suddenly and project compiles fine! no any single error now!
I want boost to work anyway, so I can use it in projects, but I can't manually edit all those header files and change <boost\... to original locations.
Please help me to get rid of this issue.

make sure you download and install the correct boost version. Installing it in the visual studio directories is possible, but not advised. I suggest you use one of the packages from here. Assuming you use visual studio 2017 and you are developing for 64bit, this could perhaps be the correct package for you.
make sure you do both: adding the include search path and the library search path to your visual studio.
The include search path should point to the boost-installation root directory (the one that contains the Jamroot file and a boost subdirectory). The library search path should point to the correct library subfolder within the boost installation. This is one of the subfolders that start with lib64-msvc-**.* (or lib32-msvc-* if you're developing for 32bit).
The default install path of the binary boost package above will install it into C:\local\boost_<boost version>. Make sure you use the paths from this installation directory and follow the instructions here.
Example:
Include search path: C:\local\boost_1_64_0
Library search path: C:\local\boost_1_64_0\lib64-msvc-14.1

Related

visual studio 2019 - C++ cannot open source file

I am using Microsoft Visual Studio Community 2019 Version 16.8.4 on a Windows 10 machine.
I have established that my include files live in "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\include" because I can actually see them listed there. However, I get an error with the line #include <cstdio>.
I have tried right click on project name to bring up a context from which I chose 'Properties'. From the "Solution Project1 Property Pages", I selected "Debug Source Files" and then entered the full directory path to the include files.
I still get the error
You need to add the directory where the headers are found to the project properties under either C/C++ -> Additional include directories or VC++ -> Include directories.
And note that you need to make sure that the directory is added for all project configurations/platforms you wish to be able to build. The Debug source files item is only so that files can be found when running the debugger and have nothing to do with the project build stage.
I ran Visual Studio Installer and noted that one of the workloads, 'Desktop development with C++' had not been activated. After activating it and downloading the required or missing binaries, I am now able to create an empty project using an example of the quintessential 'Hello World' program such as #include int main(){printf("Hello, world");return 0;}
#include <cstdio> is part of the C++ Standard Library headers, if you are getting the error E1696: 'cannot open source file, you might have to retarget the solution/project. Do the following:
Right-click the Solution in the Solution Explorer pane;
Retarget solution;
Follow the steps/press OK.
It worked for me when I couldn't find Standard Library headers, hopefully, it works for you as well.

Visual Studio 2015 can't find header files

I I realize that this problem has been asked before, but I cannot seem to apply the answer in my version of Visual Studio. It will only recognize header files I copy to the project directory.
VS can't find the file 'jni.h':
The header file is located in following directory:
The directory is added to the 'Include directories' option:
Am I missing something obvious?

Visual Studio not using additional include directories for KinectBridgeWithOpenCVBasics D2D C++ Sample, but does for other solutions.

I'm working on adding some openCV features to a couple projects that use the Kinect and openGL/freeGLUT. I have downloaded and installed OpenCV using the pre-built libraries and successfully run a simple sample. Now I want to work with the Kinect Bridge with OpenCV Basics sample from the Kinect for Windows Developer Toolkit to get a better idea of how to use OpenCV with the Kinect. I downloaded the sample into my projects folder, opened the solution in visual studio and built it. I got the following errors:
Error 1 error C1083: Cannot open include file:
'opencv2/core/core.hpp': No such file or
directory c:\users\justin\documents\visual studio
2010\projects\kinectbridgewithopencvbasics-d2d\OpenCVHelper.h 17
and
Error 2 error C1083: Cannot open include file:
'opencv2/core/core.hpp': No such file or
directory c:\users\justin\documents\visual studio
2010\projects\kinectbridgewithopencvbasics-d2d\OpenCVFrameHelper.h 13
Initially I thought these errors were due to forgetting to specify the additional include directories. I added the same property sheet that my other OpenCV projects use to this one, but the errors remained. I tired copying the header files into the project folder: same thing. It seems like the only thing that works is specifying the full absolute file paths in the #include statements. I want to avoid doing this because visual studio wants me to change every #include in every file used in the project, including the openCV header files. I also tried shortening the name of my project folder in case the file path was too long (though I'm pretty sure that's more of an issue for the header file paths), but again no change.
The include directories and #includes that I'm trying to use are the same as in my other projects. I'm using Visual Studio 2010 on Windows 7 x64 based system.
Why would the additional include directory work for other projects, but not this one?
Usually when I see something like this it turns out to be a bad character in one of the prior include paths or other options that's messing everything up after it. I would take a look at your the command line page in the project configuration and see if you can spot anything amiss.

Trouble With Building Live555 Media Server in VS2005

This could be a very silly question to any long time C++, visual studio or live555 users but I am having problems building the live555 source code with visual studio 2005. I have found a good walk through guide for creating the projects manually because .mak files are no longer supported by newer versions of visual studio but am still having problems. It seems that visual studio cannot open the .hh files that come in the include folders and I have added to the header folders of each seperate project.
Is there something special you have to do to the compilier or a plugin for the IDE to allow VS2005 to open .hh header files?
This is the error I am getting:
fatal error C1083: Cannot open include file
'BasicUsageEnvironment.hh': No such file or directory.
It seems to me that Visual studios cannot find the file, rather than it not being able to open that file type. If you right click on your project and go to
Properties->C/C++->General->Additional Include Directories
Now browse to the location of the .hh file and add it to the path. Visual studios should now be able to find the file in question. You may also have to add library paths to your solution. Please let me know if there are additional errors.

How to include boost::thread in your C++ project?

What do I need to do to include boost::thread in my project? I have copied the whole thread folder to my working path (I wish to be able to run this on several computers) and I get
fatal error C1083: Cannot open include
file:
'boost/thread/detail/platform.hpp': No
such file or directory
From the line #include "thread/thread.hpp"
What gives?
edit:
Even if I just link to the boost folder where the precompiled binary installed and I use #include <boost/thread/thread.hpp> I get
fatal error LNK1104: cannot open file
'libboost_thread-vc90-mt-1_41.lib'
Unfortunately boost::thread is not a "header-only" library -- hence you need to have it compiled. There are basically two ways to go around it.
you download a prebuilt install package from boostpro (assuming that you are on windows) -- https://sourceforge.net/projects/boost/files/boost-binaries/
you can build it yourself - see http://www.boost.org/doc/libs/1_35_0/more/getting_started/index.html
Once you have downloaded, unzipped and installed the boost libraries in your Visual Studio environment, and told the Visual Studio project where the Boost libraries live, you are not quite finished yet. There exist a number of libraries in Boost libraries that require that you build them yourself. Boost threads is one such library.
Build the bjam.exe program if you have not already done it. Probably the simplest way to is to get and run it direct from BoostPro, telling the installation which of the libraries (threads) you wish to install – you don't have to install all of them.
Go to the C:\Program Files\boost_1_46_1\tools\build\v2\engine\src directory and run build.bat from the command prompt. Running the build.bat script will create bjam.exe inside this directory:
C:\Program Files\boost_1_46_1\tools\build\v2\engine\src\bin.ntx86
Select the bjam.exe into in your PATH environment variables. Include the directory C:\Program Files\boost_1_46_1\tools\build\v2\engine\src\bin.ntx86 as another environment variable.
At the command prompt, go to the C:\Program Files\boost_1_46_1 directory, enter “bjam”, waiting for approximately 5-10 minutes while the program gets created.
In your Visual Studio project select Configuration Properties -> Linker -> Input -> Additional Dependencies and enter libboost_thread-vc100-mt-gd-1_46_1.lib.
In your Visual Studio project set the project configuration properties -> Linker -> General -> Additional Include Directories, telling it the location of the stage/lib folder eg C:\Program Files\Boost_1_46_1\stage\lib.
That should be sufficient to get you going. For more comprehensive details, please see this blog posting.
I was getting compile time error for 'boost::thread'. But it is resolved when I included following header.
#include <boost\thread.hpp>
Fatal Error C1083 is a Visual C++ error. You should include the library folder from boost in your project. "C:\Program Files\boost\boost_1_41\lib" if you're using boostpro.
Also when you're downloading the thread library with boostpro, you need to check it in the list (you can also choose the compiler...).