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
Related
On Visual Studio I see one can set path of i.e. util\util.h on that side panel, right-click the project then
Properties > C/C++ > General > ...
I add util directory there and then I can do #include "util.h" on a file from another directory, instead of providing the full path util\util.h.
Besides the approach descrived, is there another way which also will allow me to #include "util.h" (not provide the full path)?
I'm not familiar with Visual Studio at all.
Within the the Visual Studio Dialog you describe under: Properties > C/C++ > General > if you select the drop down icon and select "Edit" you will see a button titled "Macros" this provides a list of available Macros for use on the "Additional Include Directories" line. Likely you will want to use: "$(ProjectDir)\util". $(ProjectDir) is the directory that your project file is sitting in.
Let say you have created a project names 'Project1'. Then there will be a 'Project1.vcxproj' file which stores the settings for the project. Visual studio also looks for any files (source or header) in the folder starting with where this project file is located. Use the relative path with respect to where this file is located.
Let say your directory structure is as follows:
-Project\
--Project1\
---Project1.vcxproj
-Source\
--header.h
Use include path as
#include "..\Source\header.h"
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\
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.
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.
I need to build this c++ project.
its failing on the line
#include <wkhtmltox/image.h>
#include <wkhtmltox/pdf.h>
fatal error C1083: Cannot open include file: 'wkhtmltox/image.h': No such file or directory
fatal error C1083: Cannot open include file: 'wkhtmltox/pdf.h': No such file or directory
clearly its not finding the file. i have the file on disk but just need to point the project at it some how.
how do i set the project up so it can see this file?
Also If its not already clear, i'm a complete novice at c++
edit:
i'm trying to build this: https://github.com/antialize/wkhtmltopdf-bindings/tree/master/wkhtmltoxcom/
Visual Studio 2008
Goto "Tools->Options->Projects and Solutions" then select "VC++ directories" and select "Include files" in the combo box at top right corner. Specify the directory where the file is present. That should solve the problem.
Or if you want to customize it per project, hit Alt F7 or go to Project -> Properties -> C++ -> General, and set the include directories.