Boost C++ Libaries in Visual Studio 2017 C++ Project - "Cannot open include file" - c++

I'm trying to add the Boost C++ Libraries to my C++ project created with Visual Studio 2017.
I have followed the instructions here.
When that didn't work I tried the advice in this post. Neither solutions worked for me.
What I have done:
Downloaded boost_1_69_0-msvc-14.1-64.exe from this precompiled boost libraries page
Installed to D:\local\boost_1_69_0
In my project I added D:\local\boost_1_69_0 to Properties > VC++ Directories > Include Directories and added D:\local\boost_1_69_0\lib64-msvc-14.1 to Properties > VC++ Directories > Library Directories
I have my project set to x64 and the above settings were set in the x64 configuration
When I try to build my project I get this error:
Error C1083 Cannot open include file: 'boost/regex.hpp': No such file or directory
Which points to this line of code in one of my .cpp files:
#include <boost/regex.hpp>

Please go to D:\local\boost_1_69_0 folder and see if you have a sub-folder named include in there. If you do, then instead of D:\local\boost_1_69_0 you need to set D:\local\boost_1_69_0\include in Properties > VC++ Directories > Include Directories
In other words, try to find the file you are including on your hard drive. Look at the full path to the file. Compare that full path with the path you added to the list of include directories (Properties > VC++ Directories > Include Directories) concatenated with the relative path you provided just before the filename in your include directive (boost). See if the two are the same.
If that does not help, then make sure you changed list of include directories for the same build configuration as you are attempting to build (if you build Debug, make sure you changed configuration for Debug too). Since VS 2015 IDE stopped making sure the two are selected in sync, which is annoying.

If your files are copied, then you have to compile the regular library.... If the same version of the compiler copies the machine.

Found out it was failing because I had included the same .cpp file which has the boost include into my unit test project which did NOT have the Include/Library folders set. The settings in my original question work now.

Related

Visual Studio C++ how to add header files in a prefix folder

I cloned a github C++ repository. The repository is not a VS project. So I manually created a VS C++ blank project and added the files from the repo to the project. The files are not copied. This is not the problem.
The repo directory looks like this:
include\NTL\*.h
src\*.cpp
*.h means a bunch of header files and *.cpp means a bunch of .cpp source files.
The problem is that the .cpp files have #include <NTL/*.h> and when I build, VS fails to locate the header files (No such file or directory). Adding the path to the include to the Include Directories in project properties didn't help.
EDIT: After some experimenting, I've found that the error has nothing to do with the prefix NTL in #include <NTL/*.h> but with whether the files are copied into project directory. Even though the files appear in VS project view, they must be copied into the project directory.
EDIT: The only way I've managed to get the project to compile is to put the whole NTL directory containing header files in project directory. Include Directories and Additional Include Directories in project properties don't seem to have any effect.
All previous No such file or directory errors were the result of some combination of:
Mismatching project properties Configuration and Platform
Some .h files were actually missing from NTL github repo, e.g. mach_desc.h.
The solution to the problem consists of the following:
Under project Properties > C/C++, add the path to the include to Additional Include Directories.
VS project has a separate set of properties for each combination of Configuration and Platform. Make sure that step 1 applies to the active Configuration and Platform. E.g. If the project's currently configured to build for Debug x64 (active Configuration:Debug and Platform:x64), make sure that step 1 applies to Debug x64, and not something like Release Win32 or Release x64, etc.
Use the Windows/Linux-specific zip package from the Downloads page of the official website https://libntl.org/download.html

How to add Include directories in Visual Studio while cross-compiling to a Raspberry Pi?

I'm working on a c++ project on my Raspberry Pi. I'm using Visual Studio 2017 to cross-compile the project to my Raspberry.
But when I try to compile the project, I get the error"cannot open source file" in lots of header files.
I already managed to compile simple projects, but now I need to Include Directories and I don't know the proper syntax to set, on Visual Studio's project properties page, the Include Directories to tell the compile where the header files are stored.
For the PCL library, e.g., I was able to include directories using '$(INCLUDE_PCL)'.
But when I try to include pi's directory '/usr/Include/ni' I can't correctly set the absolute path. Here's an screenshot of my properties page (https://ibb.co/G2dszrx). I haven't set the Linker directories yet, since I'm currently getting errors on the compiling phase.
Does anyone knows how to set absolute path to include directories correctly?
EDITED:
Trying to figure this out, I created a new project (Proj) in which I include the file 'try.cpp' stored in the raspberry's "home/pi/projects" folder. This project is in the "/home/pi/projects/Proj" folder.
In the project property page, I have:
Configuration Properties>General>Remote Build Root Directory --> ~/projects
Configuration Properties>General>Remote Build Project Directory --> $(RemoteRootDir)/$(ProjectName)
C/C++>General>Additional Include Directories --> $(RemoteRootDir)
When I compile the project this path gets created correctly, and the project is saved at the correct place, even if go further into more folders in the remote build project directory, but it can't find the include file "try.h".
How can Visual Studio know where to save the project using '$(RemoteRootDir)', but is not able to add that path include directory?
After some searching I managed to correctly add the Additional Include Directories, and Additional Libraries.
Firstly I was also using OpenNI, to work with the PCL. After many tries, I discovered that OpenNI was not correctly installed. So I managed to install it with apt-get.
Secondly, If you want to include the "/home/pi/someDIR" directory at the Raspberry device, just add "/home/pi/someDIR" to Visual Studio's additional include directories.
For you still trying to achieve this, Merlyn Oppenheim, from visual studio, set up a sample project using VS 2019 and Raspberry PI template -> https://github.com/merlynoppenheim/sample-rasp-inc-headers
For this sample project the Visual Studio properties page should have:
C/C++ -> General -> Additional Include Directories = '/home/pi/projects/vcpkg/packages/sqlite3_x64-linux/include;%(AdditionalIncludeDirectories)'
C/C++ -> Linker -> General -> Additional Library Directories = '/home/pi/projects/vcpkg/packages/sqlite3_x64-linux/debug/lib;%(AdditionalLibraryDirectories)'
C/C++ -> Linker -> Input -> Library Dependencies = 'wiringPi;sqlite3;pthread;dl'

Cannot open include file "windows.h" No such file or directory

I am trying to build a project which contain several C# projects and one C++ project in VS 2013.
But during build the above error is shown, then i googled the error and tried several things but unable to fix the issue.
Things i have tried:
1) Added Window 10 SDK's Include directory to the Additional Include Directories
in C/C++ Configuration properties.
2) Added Window 10 SDK's Lib directory to the Additional Library Directories into the Linker.
3) Making sure that include file is "windows.h" instead of "Windows.h".
Path of Windows.h file present locally in SDK directory is
C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\um
Does any have any idea how can i fix this ?
Any help will be appreciable.
Go to the project properties -> Configuration Properties -> General
then Change Platform Toolset to Visual Studio 2013- Windows XP(v120_xp).
This is what worked for me.

use of Log4cxx in visual studio 2012

I tried to build log4cxx for visual 2012 and, after 4 hours of resolving errors, the build was succesful (i'm not sure :)).
As a second step I tried to create a vs project to test logging.
I used this example but it keep tell me that
mainapp.cpp(2): fatal error C1083: Cannot open include file:
'log4cxx\logger.h': No such file or directory
I already specified in the linker the path of directory debug in additional library directories and I added "log4cxx.lib" additional dependencies .
I'm confused and I don't know how to make it work
thanks in advance for your help
You also need to add the directory, where headers for log4cxx are. This is not for linking phase, but for compiler phase.
This can be done with Project Properties -> Compiler -> Preprocessor (I think, I don't have VS opened now)
You don't include .lib. This file is for linking.
You need to add to includes the directory, which contains directory log4cxx, and that (log4cxx) directory must contain logger.h!

Why can't Visual Studio compile my QT Project because it doesn't find the libraries?

I have a project that compiles perfectly at school. However, when I try to compile it, it says: "fatal error C1083: unable to open the include file: 'QtCore/QDate' : No such file or directory"
I've installed QT properly, the environment variables are set and in the project I included this: "C:\Qt\4.7.4\include"
Does someone have any clue?
Well the error is pretty clear: it can't find the header file.
So make sure that you have added the correct include path to the projects properties (Configuration Properties -> C/C++ -> General -> Additional Include Directories). Double check that you did this for all the build targets (debug, release, etc).
Next do a manual check, by appending the included 'QtCore/QDate' to the path you added to the project properties, and if the resulting full file path points to the actual file you want to include.
Also check the global visual studio settings for any conflicting include paths: Tools -> Options -> Project and Solutions -> VC++ Directories -> Include files