How to reference header files in visual studio 2017 project - c++

I have downloaded and tried to build The oxygine engine project with VS 2017 Community. The stringutils.cpp file from it gives me the following when I try to compile:
C1083: Cannot open include file: 'SDL_stdinc.h': No such file or directory
hovering the #include statement it says cannot open source file 'SDL_stdinc.h'
I checked
Properties->C/C++->General->Additional Include Directories
and it references the path the header files are in. I have even added another path representing the absolute path. I tried a different folder, a different download of the header files, all to no avail.
What do I need to do to get this right?
Is there any reason for a header to not work? (version mismatch or something)
Is a header not working if the corresponding dll or lib is missing?
If so, how do I know it is found by VS?

The problem was the path for oxygine in the oxigine project properties was setup like this ..\..\..\..\SDL\include\ but had to be setup like that ..\..\SDL\include\

Related

Visual Studio C++ add standard header location only with environment variable

I have an external dependency in my project which I can't change. It is built with some very complex Python which calls some more build tools.
This all eventually boils down to compile error: the C++ just cant find a header file.
The header file is included like this:
#include <sqlite3.h>
The question:
Is it possible to add a custom include directory to Visual Studio C++ with the help of just environment variables. And if it is - how?
I can't change the solution nor project nor source files - they all are being download automatically
I'm using most recent visual studio - 2017
Is it possible to add a custom include directory to Visual Studio C++
with the help of just environment variables.
I'm afraid the answer is negative.It's not possible to achieve this goal only with Environment Variable.
Please check this: When compiling the project in VS, if the compiler encounters an #include statement, it tries to open the specified file. If the file is an absolute path, it only tries to load from that specific path.
If the file is a relative path, it tries to load from the directory of the file being compiled first. If the file is not found in the same folder as the cpp file, the compiler tries each of the paths in its 'Include Directories' list to find the file.
And in VS IDE, we can set the Include Directories or Additional Include Directories to set the search path.So if I have a header file Test.h, and I use statement like #include <AbsolutePath\Test.h>, the compiler can find the header.
If i use statement like #include <Test.h>, the header file can't be found until I set the search path. In this situation, I can set the Additional Include Directories for all both debug and release to make the compiler find the header file (Test.h locates in Company folder):
Note: But one point we should know is most of the time, when we change the settings in Project=>Properties we actually is modifying the project file.(xx.vcxproj).
As you mentioned above, we can't make any change to project files, so
we can't achieve the goal by this way. Instead i think you can try
using
Directory.build.props
file.
Create a Directory.Build.props file, move it to root directory of your project folder. For me: C:\Users\userName\source\repos folder. Add the content like below into it:
<Project>
<ItemDefinitionGroup>
<ClCompile>
<AdditionalIncludeDirectories>C:\Company;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
</ItemDefinitionGroup>
</Project>
We can put the header file into the C:\Company(We can specify our folder in this way) folder and the compiler can find it. Also, we're not doing any change to Solution, project or source file.
Please let me know if it's helpful:) Any feedback feel free to contact me.

How to compile dlib 19.2 in visual studio 2015 without using cmake

I am using Dlib for face landmark detection for my academic project.
When I am running Dlib 19.2 face_landmark_detection_ex.cpp file in Visual Studio 2015 express, I wasn't able to get the results.
The steps followed
Created new project.
Added existing face_landmark_detection_ex.cpp and source.cpp file from dlib\all folder and added same files to project folder
In VC++ directories added this path D:\dlib-19.2\dlib-19.2 as Include Directories.
Downloaded shape_predictor_68_face_landmarks.dat file.
In the command line argument 'shape_predictor_68_face_landmarks.dat download.jpg' here shape_predictor_68_face_landmarks.dat i have added in project folder and download.jpg is my image file .
Added dlib/external folder to project.
Added #define DLIB_JPEG_SUPPORT
Questions: So many errors in file and not able to understand what is happening.
Your project is not inheriting the include directorys. I think you set "D:\dlib-19.2\dlib-19.2" as the only include dir. Errors like "cannot open source file string" are not related to your code, they are related to your project settings.
Also note:
Again, note that you should not add the dlib folder itself to your compiler's include path. Doing so will cause the build to fail because of name collisions (e.g. dlib/string.h with string.h from the standard library). Instead you should add the folder that contains the dlib folder to your include search path and then use include statements of the form #include . This will ensure that everything builds correctly.
Correct your includes. If E:\dlib-1.92.2\dlib is in your include path, then you should use: #include <image_processing/frontal_face_detector.h>
To fix the cin/cout errors, use std::cin, std::cout and std::endl

Dlib Error: error C1083: Cannot open include file:'type_safe_union/type_safe_union_kernel.h'

I'd like to use the image processing package of Dlib (C++ library) in Visual Studio 2013.
I created an empty project and added "dlib-18.16\dlib\all\source.cpp" to my Source Files in the Solution Explorer. Then, I added the path to dlib-18.16 to my Include Directories in VC++ Directories and I also added the path to dlib-18.16\dlib to my Additional Include Directories in C/C++ General of Visual Studio.
I can run the file matrix_ex.cpp which is one of the examples of Dlib, but I can't run the file face_detection_ex.cpp because of the error " Cannot open include file:'type_safe_union/type_safe_union_kernel.h' " which is actually caused by the line #include <dlib/image_processing/frontal_face_detector.h>
How can I resolve this issue? Why the program finds some header files but it can't find the others while they are all located in the same folder?
You need to add the dlib folder itself to the Include Directories in VC++ Directories, you instead added the folder above it.
By extension that would mean your include directive needs to be #include <image_processing/frontal_face_detector.h>.
Let me list a hypothetical example to explain better. You downloaded dlib-18.16.tar.bz2 and extracted it to c:\projects. This creates a folder named c:\projects\dlib-18.16. Within VC++ Directories you added c:\projects\dlib-18.16 to the Include Directories.
However this isn't correct, you should remove that directory and instead add c:\projects\dlib-18.16\dlib as that is the include directory for the project.
That will cause #include <type_safe_union/type_safe_union_kernel.h> to load C:\projects\dlib-18.16\dlib\type_safe_union\type_safe_union_kernel.h as well as similar internal links between files.

How to add a header file in Visual Studio 2013, C++

I use Visual Studio 2013 to build a program. I have got some problems...
a) an error:
c:\users\wojciech\desktop\cryingdamson 0.3.6 (8.60) v8.2 source\otpch.h(28): fatal error C1083: Cannot open include file: 'libxml/xmlmemory.h': No such file or directory
My code:
#include <libxml/xmlmemory.h>
I have included that file in Visual Studio 2013 to header files and I have even it at libxml folder. I can not still build solution (compile) because of that error.
Please help me, I am new to Visual Studio. I have tried to add xmlmemory.h file to project properties, but it seems that it doesn't see the file.
Okay, in folder "c:\users\wojciech\my documents/visual studio 2013/projects/consoleapplication3" there is a file named MainProject.sln, which type is microsoft visual solution. In the same folder I have added libxml folder and in the folder I have put xmlmemory.h. The problem is I still can not compile the program.
I use windows 7.
You Need to add the parent Folder of libxml to the include path. Say if the Folder structure Looks like
some_project
include
libxml
xmlmemory.h
...
you Need to add the include Directory to the include path
Where is your xmlmemory.h? Of #include <.../libxml/xmlmemory.h> try a complete path in the ... part.
The path libxml/xmlmemory.h is in fact ./libxml/xmlmemory.h where ./ means the location of your workspace.
===============Next is added according to your comment==========================
Just using #include "..\libxml\xmlmemory.h" would compile. So your workspace path is therefore c:\users\wojciech\my documents/visual studio 2013/projects/consoleapplication3. Under your workspace there should be a folder MainProject where your existed source files are located. So .\ means the path c:\users\wojciech\my documents\visual studio 2013\projects\consoleapplication3\MainProject.
Note that you should use \ other than / to represent your file hierarchy in your project and that you should use "xxx.h" other than <xxx.h>.
You can also use this method: open VIEW->Property Manager, right click on MainProject and open Properties, in C/C++ -> General -> Additional Include Directories, add your folder libxml to it. Then all files under your libxml folder would become a part of your solution. You can just use #include "xmlmemory.h>" to make it compile.
Either way is supposed to compile.

Cant find the header when I linka .lib in visual studio 2012

so im trying to link the 32 bit GLFW.lib and I placed it on my desktop and did this:
http://s1.postimg.org/40q6d5367/Untitled.png
and made sure to include #include <GL/glfw.h>
but it just gives me this everytime
Error 1 error C1083: Cannot open include file: 'GL/glfw.h': No such file or directory
There should be the include file that comes with the library itself, i.e. the gl/glfw.h (together with a bunch of other gl/gl...h files probably).
This file (these files) needs to be placed somewhere where the compiler can find it when it encounters an #include statement, i.e. in one of the directories listed under INCLUDE in the project or compiler settings, e.g. under Tools / Options / Projects and Settings / VC++ Directories / Include files (see here)