Visual Studio 2010 can't find iostream - c++

I just installed Visual Studio 2010, and wanted to test it out by writing a hello world application.
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World!" << endl;
return 0;
}
After trying to compile this I get this error
error C1083: Cannot open include file: 'iostream': No such file or directory
Here are my visual studio include directories
$(VCInstallDir)include; $(VCInstallDir)atlmfc\include; $(WindowsSdkDir)include; $(FrameworkSDKDir)\include;
And my library directories
$(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSdkDir)lib;$(FrameworkSDKDir)\lib

If you are unable to build a simple hello world application then it suggests that either Visual Studio or the Windows SDK isn't installed correctly. Have you downloaded and installed the Windows SDK? (note: if you need to build for XP you might need to use the Win7 SDK instead)
I seem to recall that after installing the Windows SDK you may need to 'integrate' it for use with VS2010. Each version of Visual Studio can have a different default SDK that it builds against. You may need to run the SDK Configuration Tool to register it for use with VS2010. Alternatively, you might need to check the 'Platform Toolset' settings in the project, as described here
Ultimately, once that is correctly setup then you should be able to build simple C++ apps without any further configuration.

The pages given below may help you:
1.) http://msdn.microsoft.com/en-us/library/8z9z0bx6.aspx
2.) http://msdn.microsoft.com/en-US/library/hdkef6tk.aspx
<iostream> is normally stored in the C:\Program Files\Microsoft Visual Studio 10\VC\include folder. First check if it is still there.
the /P compiler option is uese to preprocess helloWorld.cpp(say),this will generate helloWorld.i, and then you check to see where iostream is getting included.
and the builded log should be helpful as well as using the /showincludes option to show the paths to the include files.

Go through the normal easy process of creating a new Project --> Templates: Visual C++ --> Win32 Console Application. If not, search your HDD for iostream and set the include path manually.

Related

FLTK on Visual Studio 2019 x64, "Cannot open include file: 'dirent.h': No such file or directory

I am using the FLTK library in Visual Studio Community 2019 and building my application for x86 works fine. Now, I would like to build it for x64. However, I am getting the error "Cannot open include file: 'dirent.h': No such file or directory.".
The error occurs in the file, named 'filename.H'. This header file comes with the FLTK library.
Has anyone an idea how I could fix this problem?
Update:
The dirent.h library is not recognized, because its an C POSIX library, as described in the link here below. However, the question still remains, namely, how can I fix this problem?
<dirent.h> in visual studio 2010 or 2008
The link above refers to a link with an alternative dirent.h file. I've tried to include this file in my project, however, now another errors occur. These errors occur in the file Fl_Native_File_Chooser.H. The type specifiers fl_OPENFILENAMEW and fl_BROWSEINFOW are unknown in this file.
On Windows, dirent.h should not be included in the FLTK code. Even though it is 64 bit, WIN32 must be defined when using the FLTK libraries (https://www.fltk.org/doc-1.3/preface.html). Your problem will probably be solved if you define WIN32 at the beginning of your code or if you add WIN32 in your Visual Studio project properties - C/C++ - Preprocessor - Preprocessor Definitions, in x64 platform.
The way I would create an x64 solution is
Open ide\VisualC2010\fltk.sln
If you are using another version of Visual Studio, let it convert.
Change the solution configuration to Debug (somehow Visual Studio always defaults to Debug Cairo)
Click on solution platforms and select Configuration Manager
When the Configuration Manager appears, under Active solution platforms select New
When the next dialog appears, under type or select new platforms select x64
Click on the OKs etc to close the windows
Now change the solution platform to x64 and start the build.
You shouldn't get any dirent.h errors.

error while building a Hello World wxwidgets app with visual studio 2019

I'm trying build wxwidgets Hello World sample program in visual studio and i'm using prebuilt wxwidgets instead download that and build it myself.
and after configuring visual studio project for wxwidgets i always facing with this error:
Error C1083 Cannot open include file: '../../../lib/vc142_x64_dll/mswud/wx/setup.h': No such file or directory wxwidgets_programming_cpp C:\wxwidgets\include\msvc\wx\setup.h 140
where is the problem. I think i configured visual studio project in a wrong way. can you help me how to configure visual studio project for a regular wxwidgets app?
You need to define wxMSVC_VERSION_ABI_COMPAT in the preprocessor definitions to use these binaries, which will result in using the correct vc14x prefix instead of vc142 used by default. This is already supposed to be done by wxwidgets.props, at least for the DLL configuration which you seem to use, so I am not sure why it doesn't work for you if you do use this file, but at any rate this symbol must be defined and it isn't in your case.

I just installed visual studio and ran into some errors specifically The WindowsSDKDir property is not defined. Some build tools may not be found

Just installed visual studio 2019 on windows 10, was using visual studio for the first time and ran into the following error, It's a basic hello world console program that I tried to run.
error C1083: Cannot open include file: 'corecrt.h': No such file or directory
1>Done building project "ConsoleApplication2.vcxproj" -- FAILED.
Severity Code Description Project File Line Suppression State
Warning MSB8003 The WindowsSDKDir property is not defined. Some build tools may not be found. ConsoleApplication2 C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets 434
I tried searching for this error over YouTube and of course here, and also Microsoft's offical forum but couldn't find anything.
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World!\n";
}
the code looks just fine.
I ran into the same issue today. It turns out I didn't check the Win10SDK to save disk space while installation.
Solution:
In VS, go Tools menu=>Get Tools and Features=>install the Windows 10 SDK(10.XX.XX.XX)
Once installed, launch VS and open your project, right-click your project(NOT Solution)->properties->General->Windows SDK Version, check the value should be 10.0 instead of blank.
Then the compiling just worked.
I've got the same issue and turned out that I haven't installed Windows SDK. It can be done by typing "Install Windows SDK" into visual studio's search prompt
I had same problem when I installed Visual Studio 2019 on Windows7 and opened project created in Visual Studio 2017 (witch wasn't installed on that machine).
To solve the problem I went to project Properties -> General -> Windows SDK Version
And changed it from 10 to 8.1.
I fixed this issue by repairing Windows SDK. Now it's working as expected.
Steps:
Go to Settings>Apps & Features.
Click on Windows Software Development Kit - Windows 10.0.18362.1
(Note: Version number might be different for you)
Click on Modify.
Select Repair from options.
Click Next.
Restart VS and try running your project.
I was just having thesame issue so I figured maybe the headers were in a different directory than where the program is searching. When I went looking for tge header files none existed. So the problem is probably with iostream not existing.

Visual Studio 2013 and Kinect SDK 2.0 Cannot find or include <NuiApi.h>

I am learning Kinect development using C++ in Visual Studio 2013 (Desktop version on Windows 8.1). I have downloaded the Kinect SDK 2.0 from Microsoft. According to my understanding, NuiApi.h is part of Kinect SDK 2.0. However, I cannot include it (#include says Cannot open source file). Have searched my computer for the file but couldn't find it. Reinstalled Kinect SDK with no luck. Below is the related part of the code:
#include<iostream>
#include<Windows.h>
#include<kinect.h>
#include<NuiApi.h>
A similar header, NuiKinectFusionApi.h, can be included without a problem.
You are mixing the 2 kinect versions!
for the kinect v1, you need to download kinect v1.8 drivers and then use the NuiApi.h
for the kinect v2, you need to download kinect v2.0 drivers and then use the kinect.h
You need to follow these steps to include #include.
1)Include windows.h in your source code.
2)To use the NUI API, include MSR_NuiApi.h. Location: Program Files\Microsoft Research KinectSDK\inc
To do this, you probably want to add that path to your project
Right-click on your project, properties, VC++ directories
Add ;C:\Program Files\Microsoft Research KinectSDK\inc to the end of the include paths
Add ;C:\Program Files\Microsoft Research KinectSDK\lib to the end of the libraries paths
then add #include <MSR_NuiApi.h>
to the includes at top of your source file. If you're using precompiled headers then you should put it below the stdafx.h include, or just add it to stdafx.h instead.
3) To use the Kinect Audio API, include MSRKinectAudio.h. Location: Program Files\Microsoft Research KinectSDK\inc
4)Link to MSRKinectNUI.lib. Location: Program Files\Microsoft Research KinectSDK\lib
5.Ensure that the beta SDK DLLs are on your path when you run your project. Location: \Program Files\Microsoft Research KinectSDK
This means that your binary needs to be able to find these files at runtime.
The easiest way to do this is to add them to your system path; go to
start menu
right-click computer, properties
advanced system settings
environment variables
PATH, in your user or system settings - edit and append ; then the path given
You may then need to restart Visual Studio to pick this up, or it should be registered when you open a new command prompt.
Or, if you don't want to change the system settings, you can e.g. add it to an open command prompt with
PATH=%PATH%;C:\Program Files\Microsoft Research KinectSDK
or you can work out exactly which files there are necessary and copy them into the same directory as your binary, etc.
Source : Getting the Kinect SDK to work with visual studio 2010 in c++
Hope that helps :)

Boost compiling with MSVC 11 (VS 2012)

How to build Boost (I tried version 1.48.0) with Visual Studio C++ 11? bootstrap.bat cannot find toolset vc11. I added toolset vc11 to F:\Programming\boost_1_48_0\tools\build\v2\engine\build.bat but got a message:
ERROR: Cannot determine the location of the VS Common Tools folder.
EDIT: The Ferruccio answer works for VS 2012 Express and Boost 1.51.0 too.
This answer works beautifully for:
VS2012 (Visual Studio 2012 Update 2)
or VS2015 (Visual Studio 2015 Update 2)
Windows 7 x64
or Windows 10 x64
Boost v1.53
or Boost v1.60
In a nutshell
Open a Visual Studio 2012 command prompt. From the start menu its: All Programs..Microsoft Visual Studio 2012..Visual Studio Tools..x64 Native Tools Command Prompt.
Unzip boost_1_53_0.zip to C:\boost153.
run bootstrap.bat
run bjam.exe
In any new C++ project, include the path to the Boost libraries, as per the screenshot below.
(optional) Step-by-Step Instructions
Install Visual Studio 2012.
Install Update 2.
Download Boost from SourceForge.
Unzip into "C:\boost153"
Open a Visual Studio Command prompt with Administrator privileges. From the start menu, its All Programs..Microsoft Visual Studio 2012..Visual Studio Tools..x64 Native Tools Command Prompt.
Change to the boost directory with cd c:\boost153.
Run bootstrap.bat.
Run bjam.exe. This builds all of the libraries.
There may be some warnings, but you can ignore these.
When it has finished compiling after about 5 minutes, it states:
The Boost C++ Libraries were successfully built!
The following directory should be added to compiler include paths:
C:/boost153
The following directory should be added to linker library paths:
C:\boost153\stage\lib
This is important, we will need to add these two paths to any new C++ project.
Create a new C++ project.
As noted a couple of steps ago, add C:/boost153 to the compiler include path and C:\boost153\stage\lib to the linker library path.
Right click on the project, select Properties, select Configuration Properties..VC++ Directories. See the two portions of bolded text in the screenshot below):
Let's run a simple program that shows off the power of boost, by adding support for foreach loops:
// Source code below copied from:
// http://www.boost.org/doc/libs/1_53_0/doc/html/foreach.html
#include "stdafx.h"
#include <string>
#include <iostream>
#include <conio.h> // Supports _getch()
#include <boost/foreach.hpp>
int main()
{
std::string hello( "Hello, world!" );
BOOST_FOREACH( char ch, hello )
{
std::cout << ch;
}
_getch();
return 0;
}
Result:
Hello, world!
More Answers
See Boost compiling with MSVC 11 (VS 2012).
See Official Boost docs on compiling with Visual Studio under Windows.
See Building Boost v1.64.
Update 2016-05-05
Checked with Win10 x64 + VS2015.2 + Boost v1.6.0.
I managed to get it to build by following these steps:
Open a Visual Studio command prompt. From the start menu it's: All Programs|Microsoft Visual Studio 11|Native x64 Command Prompt.
Unzip boost_1_48_0.zip and set the working directory to boost_1_48_0
run bootstrap.bat
run bjam.exe
It does generate a lot of warnings about not being able to detect the toolkit version, but it proceeds anyway.
Update: I created GitHub repo called cclibs which makes it simpler to build Boost and some other C++ libraries.
bootstrap.bat
bjam.exe --toolset=msvc-11
Check that your installation is correct by confirming the output of the following command:
C:\>echo %VS110COMNTOOLS%
C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools\
Here's some simple instructions to follow to get rid of warnings when bootstrapping: http://landoftheninja.blogspot.com/2011/11/visual-c-11-and-boost.html
Don't miss his follow-up post that deals with the automatic linking.
vs2012 ERROR: Cannot determine the location of the VS Common Tools folder.
vcvarsall.bat need call a "reg.exe" which in "C:\windows\system32\".
if not in search path,will cause this error.
Add C:\windows\system32 to %PATH% will solved the problem.
In addition to above answers, I find BlueGo really helpful for building boost versions with MSVC 10/11/12. You can select different configurations and just select build, and it does the trick.