Using tclap-Templatized C++ Command Line Parser Library in Visual Studio2010 - c++

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.

Related

I can't include a boost header file mapped_file.hpp in my project

I need to include "\boost\iostreams\device\mapped_file.hpp" in my project. I tried:
#include <\boost\iostreams\device\mapped_file.hpp>,
but it couldn't work. Therefore, I used:
#include "C:\path\boost\iostreams\device\mapped_file.hpp".
As a result, the system could find "mapped_file.hpp" file. However, when I build the project, the system complains:
C:\path\boost\iostreams\device\mapped_file.hpp(14): fatal error C1083:
Cannot open include file: 'boost/config.hpp': No such file or directory
This tells me the way I fixed the first error is incorrect.
I have another project downloaded from a repository that uses boost library. This project is already built successfully in my PC. Everything for the boost library in my PC comes from this project, and the header file I need to use is located in "C:\path\boost\iostreams\device\mapped_file.hpp". In this case, how should I add a path or include "\boost\iostreams\device\mapped_file.hpp" to fix my current problem?
Thanks in advance!
I need to include "\boost\iostreams\device\mapped_file.hpp" in my project.
Actually, no, you don't. You might need to include "boost\iostreams\device\mapped_file.hpp" (no leading slash) in your project, but that leading slash will make it impossible for the compiler to find the header file (unless you installed boost to your root directory – rather rare).
In addition, make sure the compiler knows to look in C:\path\ for included headers. As discussed in the comments, this can be done in Visual Studio 2012 via Project properties → C/C++ → General → Additional Include Directories.

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 include file error but able to locate file

I'm getting the following error :
"fatal error C1083: Cannot open include file"
for one of my header files being #included in stdafx.h. I have set the include and library paths in the project dependencies, Tried to include them in additional include section. On top of that when I right click the
#include <BCGCBProInc.h>
it is able to open the file and show it to me. So it can find and open the file but instead gives me the error. I am using VS2012 on Windows 7 and the header is in a different location then the project.
What am I doing wrong / not doing right?
1.
#include <BCGCBProInc.h>
is not the same as
2.
#include "BCGCBProInc.h"
Different search pathes apply to both variants of including a file.
The pathes looked up when using variant 1. are those defined as default search pathes like
/usr/include for IXish systems
$(VCInstallDir)include also called VC++ Directories for VC
The pathes used when using 2. are those added via the option -I (/I for VC).
In Visual Studio, right-click your project and choose Properties. Select the VC++ Directories option in the left pane, and then look at the Include Directories and Library Directories in the right pane. Make sure they are using relative paths and not absolute paths. If they must be absolute paths, then every machine you run this project on will have to have the exact same path. Absolute paths look like this:
D:/Development/MyProject/includes
Relative paths can be done using $(ProjectDir) to make it relative to the project, or $(SolutionDir) to make it relative to the solution (if different from project), and would look something like this:
$(ProjectDir)../includes
or
$(SolutionDir)includes
What I had to do to get it to compile was change
#include "BCGCBProInc.h"
to this
#include "C:\Program Files (x86)\BCGSoft\BCGControlBar Professional Evaluation\BCGCBPro\BCGCBProInc.h"
I'm not sure why because I included the path in the VC++ Directories. When I browse for the path it changes (x86) to %29x86%29 which is what I thoght was screwing it up but that is not the case because I manually changed it back to (x86).
My plan is when I eventually get what i need to get done, I will bring the libs and includes into the project locally and make the paths relative

How to include header files in Visual Studio 2008?

I am currently trying to compile a simple program that includes two header files. I see them in the Solution Explorer, where I included them through "include existing files". However, when I run my program it get the following error.
fatal error C1083: Cannot open include file: 'FileWrite.h': No such file or directory. THe problem is that I see the file included in the Header's folder and in the code I have written:
#include "FileWrite.h"
and then the rest of the program code.
Is there something else needed to do so that the compiler can see the header file and link it to the .cpp file I'm trying to compile?
If you write in your code something like #include "FileWrite.h" you need to make sure compiler can find that file. There are three options:
FileWrite.h should either be in the same directory as your source code file (.cpp) or
Path to that header file should should be listed in project's Properties (in C/C++ -> General -> Additional Include Directories) or
Path could be set in your VisualStudio - add it to Include Files in Tools->Options->Projects and Solutions->VC++ Directories
Which of these options shell be used depends on whether that header originates from this project (1st option) or some other project (any of other two options).
There are two ways to do this.
1) Only for the current project
Select your project -> properties -> C/C++ -> General -> Additional Include Directories -
Include your header file directory.
2) For all projects
Tools -> Options -> VC++ Directories -> Include files - Add the header file directory.
Refrain from using 2, as it would be difficult to figure out dependencies for a project when compiling it on a system different than yours.
When including files the compiler first looks in the current directory (the directory which contains the source .cpp file) then it looks in the additional include directories. If FileWrite.h isn't in the same directory as your source file check the additional included directories.
In the project's property page look at the additional include directories and see if they include the folder in which FileWrite.h is in.
You said the file is in the "headers" folder. This could either mean the headers filter or an actual headers directory on the filesystem. When including a file from your own project you need to specify the path from the file you're including into. So, if you had something like so:
src/main.cpp
include/my_object.h
You would use #include "../include/my_object.h" in main.cpp.
That's for directories. The folders you see in your project are called filters and have absolutely no relation to the directory structure of your project unless you force it to. You need to be paying attention to what the structure looks like in windows explorer to ascertain what path to use in an include statement.

using header files from another project (directory)

I am using Visual Studio 2008, and I need to use certain header files from another project. I have tried to add the path in "Additional Include Directories" in C/C++ General properties pane, but my project still puts out the same errors
(fatal error C1083: Cannot open include file: 'tools/rcobject.h'.
All the other cpp and header files I am using I added as existing files from another directory, and for some headers it puts out an error and for others it doesn't. There was no change in errors after adding additional include directories.
Can someone help me, I am stuck as I need to Debug...
In the "Additional Include "Directories", did you put the path to the "tools" directory, or the path to the directory that includes the "tools" directory? It needs to be the latter.
How the preprocessor works to resolve #include directives, is to take the path specified in the #include and then append it to each of the paths specified in the "Additional Include Directories" (and some other places specific for the project). So, you need to make sure that the path specified in the "Additional Include Directories" plus the path you gave to the #include exactly matches the path to the file you are trying to include.
For example, suppose you have the following file you want to include:
c:\blah\bletch\foo\bar.txt
Then you did this:
#include "bar.txt"
Then you would need to make sure that "c:\blah\bletch\foo" was in the "Additional Include Directories".
Or if you had done this:
#include "foo\bar.txt"
Then you would need to make sure that "c:\blah\bletch" was in the "Additional Include Directories".
Enable the build log (I don't know from the top of my head where it is, shouldn't be too hard to find) and see if the paths you specify appear in the compiler command line. If not you're probably doing something wrong. Using additional include directories should just work. Just make sure you're using the right directory separator and you fill them in under the correct configuration (Release/Debug).
Regards,
Sebastiaan