How to add a header file in Visual Studio 2013, C++ - 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.

Related

How to reference header files in visual studio 2017 project

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\

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.

Cannot open header file in Visual Studio 2012

I am using Visual Studio 2012 and trying to import header files in the project, but have been failing miserably. Here is what I have tried to do:
#include "gevents.h"
#include "gobjects.h"
#include "gwindow.h"
int main(){
int x=1;
return 0;
}
I have added these three header files in the project location:
C:\Users\Shaby\Documents\Visual Studio 2012\Projects\ConsoleApplication39
In addition, I have also gone to Project properties ->Configuration Propertues -> C/C++ ->General and included the above path location in "Additional Include Directories" but this had yielded nothing. Instead, I am getting the following error:
Unable to start program C:\Users\Shaby\Documents\Visual Studio 2012\Projects\ConsoleApplication39\Debug\ConsoleApplication39.exe The system cannot find the file specified
#Usman Khan ,
I have one solution for your problem.In Solution Explorer Window (if not opened then press Ctrl+Alt+l) you can see you project name.Right click on it and than Add > Existing Item. Now select your header files which you want to include & press Add. Done :) .
why are you making it complex, just keep it simple.After creating your project. Open solution explorer. Under your project name you would see a folder "header files" , add your header files in it (your header files should have ".h" extension) and then to use them include them in your source files

Error while using Boost with Visual Studio 2008

I am using Boost with Visual Studio 2008 and I have put the path to boost directory in configuration for the project in C++/General/"Additional Include Directories" and in Linker/General/"Additional Library Directories". (as it says here: http://www.boost.org/doc/libs/1_36_0/more/getting_started/windows.html#build-from-the-visual-studio-ide)
When I build my program, I get an error:
fatal error C1083: Cannot open include file: 'boost/python.hpp': No such file or directory
I have checked if the file exists, and it is on the path.
I would be grateful if anyone can solve this problem.
The boost include path is C:\Program Files\boost\boost_1_36_0\boost.
Linker path is C:\Program Files\boost\boost_1_36_0\lib.
The file python.hpp exists on the include path.
Where is the file located, and which include path did you specify? (And how is the file #include'd)
There's a mismatch between some of these But it's impossible to say what's wrong when you haven't shown what you actually did.
Edit:
Given the paths you mentioned in comments, the problem is that they don't add up.
If the include path is C:\Program Files\boost\boost_1_36_0\boost, and you then try to include 'boost/python.hpp", the compiler searches for this file in the include path, which means it looks for C:\Program Files\boost\boost_1_36_0\boost\boost\python.hpp, which doesn't exist.
The include path should be set to C:\Program Files\boost\boost_1_36_0 instead.
How do you include it? You should write something like this:
#include <boost/python.hpp>
Note that Additional Include Directories settings are differs in Release and Debug configurations. You should make them the same.
If boost placed to C:\Program Files\boost\boost_1_36_0\ you should set path to C:\Program Files\boost\boost_1_36_0\ without boost in the end.