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 have recently gone from Code::Blocks to Visual Studio, and in Code::Blocks one could just add a class and then include it straight away. However, whenever I do the same in Visual Studio with the following statement:
#include "includedFile.h"
or
#include "include/includedFile.h"
It doesn't work and instead I get the error:
cannot open include file: 'includedFile.h'; no such file or directory.
Is there some box or setting that I have to tick? Or do I have to add each header as a dependency manually?
Here is the code for the class in question:
Public.h:
#pragma once
class Public
{
public:
static const int SCREEN_WIDTH=1000;
static const int SCREEN_HEIGHT=1250;
Public(void);
~Public(void);
};
Public.cpp:
#include "Public.h"
Public::Public(void)
{
}
Public::~Public(void)
{
}
How it is being included:
#include "Public.h"
I had this same issue going from e.g gcc to visual studio for C programming. Make sure your include file is actually in the directory -- not just shown in the VS project tree. For me in other languages copying into a folder in the project tree would indeed move the file in. With Visual Studio 2010, pasting into "Header Files" was NOT putting the .h file there.
Please check your actual directory for the presence of the include file. Putting it into the "header files" folder in project/solution explorer was not enough.
Go to your Project properties (Project -> Properties -> Configuration Properties -> C/C++ -> General) and in the field Additional Include Directories add the path to your .h file.
And be sure that your Configuration and Platform are the active ones. Example: Configuration: Active(Debug) Platform: Active(Win32).
You need to set the path for the preprocessor to search for these include files, if they are not in the project folder.
You can set the path in VC++ Directories, or in Additional Include Directories. Both are found in project settings.
By default, Visual Studio searches for headers in the folder where your project is ($ProjectDir) and in the default standard libraries directories. If you need to include something that is not placed in your project directory, you need to add the path to the folder to include:
Go to your Project properties (Project -> Properties -> Configuration Properties -> C/C++ -> General) and in the field Additional Include Directories add the path to your .h file.
You can, also, as suggested by Chris Olen, add the path to VC++ Directories field.
I found this post because I was having the same error in Microsoft Visual C++. (Though it seems it's cause was a little different, than the above posted question.)
I had placed the file, I was trying to include, in the same directory, but it still could not be found.
My include looked like this: #include <ftdi.h>
But When I changed it to this: #include "ftdi.h" then it found it.
If your problem is still there it's certainly because you are trying to compile a different version from your current settings.
For example if you set your Additional Include Directories in Debug x64, be sure that you are compiling with the same configuration.
Check this: Build > Configuration Manager... > There is problably something like this in your active solution configuration: Debug x86 (Win32) platform.
For me, it helped to link the projects current directory as such:
In the properties -> C++ -> General window, instead of linking the path to the file in "additional include directories". Put "." and uncheck "inheret from parent or project defaults".
Hope this helps.
I tried the other answers here as well, but my problem had nothing to do with the include paths or files missing incorrect #includes. I had two configurations, each set to the exact same include directories. One configuration could resolve the includes, the other could not.
After selecting my project and going to Project -> Properties, I selected both configurations through the Configuration dropdown -> Multiple Configurations... option. Comparing the two I found that C/C++ -> Language -> Conformance Mode was different. The "incorrect" configuration had a value of Default for some reason, and switching it to Yes or No allowed the paths to be resolved.
TL;DR: If you have one configuration with the same include directories but the other isn't finding the files, I suggest to try comparing the configurations.
If you've tried the other answers and your include file still can't be found, here are some additional debugging steps and sanity-checks:
Ensure that you are building to a platform that is supported by your code. (If not, consider removing this platform as a target)
Verify that the filename/path is correct. Modify your source code to #include the whole absolute path of the header file instead, and see if the file can be found now. If not, copy-paste the path from your source code into a command line to validate that the file exists at that full path with no typos. Open the header file to ensure you have read access. (Change the source code back when done.)
If you've already added the path to Additional Include Directories, try clicking the drop-down combo box for Additional Include Directories, and select <Edit...>. This will show you evaluated values of paths. (If it does not show the correct evaluated values, variables in your path might not be set. Click Macros>> to see variables.) Copy-paste the evaluated path into windows explorer to validate that the path exists.
Create a new empty C++ "Windows Console Application" project. Set just the one Include Directory, and #include just the one file in your main.cpp, and see if that builds.
Is tclap-Templatized C++ Command Line Parser Library installable on windows? I want to use this library in my code in Visual Studio2010. I did following steps:
1. add the "..\include" in Property->C/C++->General-> Additional Include Directories
2. copy include folder in my project folder.
3. add #include in my main file.
But I have following error during compile
fatal error C1083: Cannot open include file: 'tclap/CmdLine.h': No such file or directory
use an absolute path in the "Additional Include Directories" setting, and make sure that it applies to your configuration as well. Don't go around copying folders in projects all willy and/or nilly, that just makes life harder. If the tclap directory is correctly added to your system include path, then #include will work; if that doesn't work, your system include path is not set correctly.
In more recent versions of VC, you will want to make sure that these settings are set in the appropriate properties files in the Properties explorer.
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.
whenever I compile my project in the Release build I get this error:
Error 29 fatal error C1083: Cannot open include file: 'NX_Win32Wrapper.h': No such file or directory
I get another one just like this, just in a different file (the error complains about a different file). The file in the second error is whichever I included first (is on top of the include list), the same goes for the first error, but its right after:
(this is the "main".cpp file,where main() is and GameV2 is my project name
#include "stdafx.h"
#include "GameV2.h"
I know there is now code, but I think I'd have to post everything :P Do you have any suggestion what should I check?
It seems that you're using Visual Studio.
Check the include directories in project properties, for Release target. You set the proper include directories only for Debug target.
You should check the "Additional include directories" - the list should usually be the same for "Debug" and "Release".