C++ Including Visual Studio header files in Qt project. <xstring> include error - c++

I have found a library to generate barcodes (libbarpp). I would like to use this library in my Qt project.
Doing a svn checkout of the source: http://libbarpp.googlecode.com/svn/trunk/ reveals a nice VS example in the src folder. I opened the project in VS and found the included header files. I have included these header files in my Qt project, however i encountered a problem when several of the files required a system header file
#include <xstring>
In VS i can see the this file is located in (on my system):
c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xstring
However the files does not have any extension and i don't really know what to do with it.
Do i need to include something in my Qt project file in order to use this VS file?
I tried including
CONFIG += stl
to my Qt project file, but with no luck.
Any help or comments is greatly appreciated.
EDIT: I'm using Qt 5.2.1 with MinGW compiler

xstring is a Microsoft specific header that contains implementation of std::basic_string and some related specializations.
It shouldn't be included directly in the first place and unless the code you are talking about is using something implementation specific from that file you should be fine replacing it with just:
#include <string>

Related

Boost Library cannot get to work in C++, Include directories not working

I recently tried to install boost libraries in C++ 14, and I added it's include paths like:
Solution Explorer > Project Name > Property Pages > VC++ Directories > "C:\Program Files (x86)\Microsoft Visual Studio 14.0\boost\boost"
I tried to compile after adding this:
#include <boost\variant.hpp>
In Error List window, I can see E1696 - cannot open source file "boost\variant.hpp" and I can't compile like before.
Then I tried with adding a backslash like "C:\Program Files (x86)\Microsoft Visual Studio 14.0\boost\boost\", still didn't work.
I also read this post and explicitly specified it's directory, but even didn't work.
Again, I read this post and did exactly same what is in given answer (as I already built project several times) , but still no success.
However, if I include a library like:
#include "C:\Program Files (x86)\Microsoft Visual Studio 14.0\boost\boost\variant.hpp"
Now compiler recognizes it, but now I can see more than 100 errors in Error List window, those errors are pointed to header files of boost libraries, not in my project file which has variant.hpp included.
All those errors are E1696 - cannot open source file "boost\<libraryname.hpp>" or E1696 - cannot open source file "boost\<subdirs>\<some other files included in libraryname.hpp>"
So, if I remove the line #include "C:\Program Files (x86)\Microsoft Visual Studio 14.0\boost\boost\variant.hpp" from my project's header file, all errors disappear suddenly and project compiles fine! no any single error now!
I want boost to work anyway, so I can use it in projects, but I can't manually edit all those header files and change <boost\... to original locations.
Please help me to get rid of this issue.
make sure you download and install the correct boost version. Installing it in the visual studio directories is possible, but not advised. I suggest you use one of the packages from here. Assuming you use visual studio 2017 and you are developing for 64bit, this could perhaps be the correct package for you.
make sure you do both: adding the include search path and the library search path to your visual studio.
The include search path should point to the boost-installation root directory (the one that contains the Jamroot file and a boost subdirectory). The library search path should point to the correct library subfolder within the boost installation. This is one of the subfolders that start with lib64-msvc-**.* (or lib32-msvc-* if you're developing for 32bit).
The default install path of the binary boost package above will install it into C:\local\boost_<boost version>. Make sure you use the paths from this installation directory and follow the instructions here.
Example:
Include search path: C:\local\boost_1_64_0
Library search path: C:\local\boost_1_64_0\lib64-msvc-14.1

How do I find the iostream header file in a Visual Studio C++ project?

I was learning more about header guards in C++ from here. One of the paragraphs there said:
Even the standard library includes use header guards. If you were to
take a look at the iostream header file from Visual Studio, you would
see:
#ifndef _IOSTREAM_
#define _IOSTREAM_
// content here
#endif
I'm interested in finding the iostream header file to see this header guard myself and to learn more about how C++ directories are structured to find files like these. I had a working C++ project in Visual Studio 2015, and in the project directory I tried dir *iostream* /s in cmd, but I didn't find anything. How can I find the iostream header file in a Visual Studio 2015 project if it's accessible?
iostream is not part of your project. It's part of c++ standard library. How about searching your HDD for it?

CritSec.h not existent (Win 8.1)

I have this sample code I'm currently using to write a dll in c++.
In this file critsec.h is included.
However on my system (Windows 8.1 Pro 64bit) Visual Studio 2013 CE can't find the source file.
Am I missing some sort of SDK or something?
In the project file belonging you your example file, you see the following additional include directories (reformatted for better reading):
<AdditionalIncludeDirectories>
%(AdditionalIncludeDirectories);
$(MSBuildThisFileDirectory);
..\..\Common
</AdditionalIncludeDirectories>
And indeed, in ..\..\Common, you will find CritSec.h
How do you include this? There are two ways. If you you use #include "something.h" the file has to be at the same location where youre .cpp is. If you use #include than the header has to be at a directory in visaul studio.

Visual Studio 2012 Error: Cannot open source file

I have source code (header and source files)of a library. I need to include the source code in my existing project. For that purpose i have copied the entire library source code directory into visual studio project folder then i included that directory to VS by using include to project option. Fine.
There is a header file say "x.h" in the library source code directory which defines some macros, and there are some other header files say "y.h" and "z.h" which are using those macros defined in "x.h". But visual studio is not recognising those macros at all when i included those ("y.h" and "z.h") header files in my main class. Visual Studio generates the error "Cannot open this source file".
Actually "y.h" and "z.h" can not find macros defined in "x.h". How to solve this error?
Is there some kind of setting need in the project properties?
My second question is that how to include some programming files in my project correctly so that i can use that library functionality correctly? I have also Include the header directories in configuration properties > VC++ Diectories > Include Directories.
Third question is that is there a way in which i don't have to include the source code to my project? remember i don't have .lib file or .dll file of that library and i cannot compile that library also.
Have you add
#include <x.h>
or
#include "x.h"
Are library files in a sub-folder? if Yes try
#include ".\subfoldername\x.h"

Creating a C++ visual studio project based on existing files

I've never worked with C++ or C. I'm trying to create a Visual studio project based on existing files which can be found here: example1.cpp together with the resources. As you can see this is example code of a book for OpenGl. I have opengl and glut present on my computer and they work ( tested it).
Based on the files mentioned above a created an empty C++ project in visual studio 2012 (i also have other versions installed if you can provide a solution in 2010 or so). I included the header files & the source file. Though I still get the following in my IDE:
with errors such as:
cannot open source file "Angle.h"
( Though the file is present in the project)
Can anyone tell me how I get these files to compile and run ?
Make sure that the file angel.h it's in the same path that the .cpp file.
Header files need to be in same directory with source files in order to use #include with quotes.
#include "header.h"
In other words Angel.h must be in same directory with example1.cpp.
However,you can add spesicific paths to your project from Project Settings>VC++ Directories and include header files which exists in those paths using
#include <header.h>