For the past hour I have been looking at multiple stack overflow questions trying including this one and this one trying to figure out why visual studio cannot open typical source files like stdio.h
I am starting out by building a new project and then selecting the "console app" option, but when I try to compile and run the simple hello world program I get the errors shown below.
Edit:
Here is the code that is generated by default when choosing the console application option in visual studio that I am trying to run:
#include <iostream>
int main()
{
std::cout << "Hello World!\n";
}
The issue was that I thought I had the Widows 10 SDK installed, but apparently I did not. I found the answer using this stack overflow thread.
I had to download the Windows 10 SDK from here and restart the visual studio IDE and it worked straight away.
Related
When I compile a simple program:
#include <iostream>
using namespace std;
void main() {
cout << "Hello world!";
}
And tun the compiled .exe on another system without visual studio installed I receive the following error:
The Code execution cannot proceed because VCRUNTIME140.dll was not found. Reinstalling the program may fix the problem.
When I compile with cl.exe I receive no errors,
does anyone know a workaround to this without installing VCRUNTIME140.dll on the systems. (I've tested on multiple windows systems including a windows virtual machine)
I've encountered this problem before and there's a simple solution to it,
The missing .dll are a issue of static linking not missing packages (in most cases),
becuase visual studio 2019 comes pre-installed with what you need.
To fix:
go to your project properties (in project tab)
Select C/C++
Change the value of runtime library to "Multi-threaded debug (/MTd)"
This will cause the compiler to embed the runtime into the app.
The executable will be significantly bigger, but it will run without any need of runtime dlls.
Get the "Visual Studio 20xx VC++ Redistributable package" for your version of Visual Studio. Then run on the target machine to install.
Bottom of this page: https://visualstudio.microsoft.com/downloads/
Or bottom of this page for older versions of Visual Studio: https://visualstudio.microsoft.com/vs/older-downloads/
I've had the same problem, mainly because originally when compiling something with C++ and turning it into an exe file, it's still gonna be an exe file that depends on libraries from C++.
But according to asd plourgy, who had a good idea to change the value of the runtime library, I wanted to share with whoever seeks knowledge how I solved it:
Go to your Visual Studio Code and follow these steps:
Click on Project
Properties
Scroll out C/C++
All Options
runtime library
Change value to: "Multithreaded-DLL (/MD)".
And that should do the trick. Afterwards, you have to obviously
save
debug
create new(exe)
open cmd and run the exe to make sure it works.
My System is: Windows 10
Here are a few pictures to make the steps easier, it's in german though:
step1:
step2:
step3:
step4:
step5:
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.
I recently started C++ programming on Visual Studio and I noticed that it always gives me the console output in the command prompt (CMD).
I am a java programmer and I'm used to working with Eclipse and Netbeans. With those IDEs, I was able to see the console inside the IDE and not in a different separate window.
Is there a way to display the console output inside Visual Studio, like Eclipse and Netbeans do?
It's infuriating. I spent hours looking for this. Visual Studio doesn't have command prompt inside the IDE.
They have it for Visual Studio code - Intergrated command prompt. But not for visual studio 2015 Enterprise. So, in other words, microsoft has command prompt terminal inside the free version of visual studio but not for the paid version
Unfortunately, the answer seems to be no.
In Visual Studio, console applications are displayed on the command prompt and not inside Visual Studio itself. Meaning that Console.WriteLine method and similar ones write your output to the console window because your application type is Console Application.
You are able to write output to Visual Studio itself by using System.Diagnostics.Debug.WriteLine as mentioned on MSDN. That will cause the debug output to appear in the Output Window inside Visual Studio. In case you don't see that view, you can choose to show it by Debug => Windows => Output.
You should bare in mind that this is not what you asked for.
This "solution" is helpful just in case you want to debug parts of your code and don't want to open the command prompt but just see the relevant output inside the IDE.
In addition, you won't be able to give input back in this output view.
The most important thing, you will not be able to execute your application correctly outside of your coding environment. So, it will work only on the IDE but you won't be able to see this output when the application is on its own (as it meant to be as a console application).
Another solution, that you might like, is to work with Eclipse.
You said that you are familiar with Eclipse as a Java developer and now you work with C++ and don't get along with Visual Studio so far.
So, you can download Eclipse IDE for C/C++ Developers.
In there you will be familiar with the IDE and you will be able to display your output inside Eclipse without any weird and unnecessary workarounds.
I'm using visual studio 2010.
And followed a simple opencv tutorial :
Installing OpenCV 2.4.3 in Visual C++ 2010 Express
However when i hit F5 compile visual studio gives me an access denied message. LNK1104
Restarting visual studio has no effect.
Running as Admin has no effect.
Completely restarted in a new project, same error.
Non of my folders use spaces, so errors cant be related to that.
I am below the max unc path length (old DOS bug)
Windows security essentials (my antivirus), has this folder excluded.
Strangly code syntax following openCV namespace etc is understood
A compilation seams to be made, but cannt run
Also run from a dos prompt in debug folder, same error access denied
using taskmanager i see my exe loaded in memory, looking with sysinternals proces explorer; i see they are loaded by Devenv.exe (part of visual studio (same icon as vs2010). but well loaded but not working.
When closing vs2010, and using procmon.exe (sysinternals), going to debug folder executing the little app i made. then cmdagent process gives one "create file" exception on the Q drive (a left over from office online). However my app isnt related to office at all, its just a small image shower, nothing reffers to that bogus Q drive ???
I somehow think the problems are related to VS2010 itself, but I have no clues of what is happening here, its one of my first c++ projects so i'm not sure where to look of what goes wrong, any help would be great.
*** update 20-3-2015
Problem whatever it is, is not related to openCV
Even the most simple C++ code like below isnt working now, what can this be ?
#include <iostream>
using namespace std;
int main()
{
cout << "it never executes" << endl;
}
Whats wrong with my visual studio suddenly ???
I used the installation CDrom of visual studio to repair it.
C++ works again now..
Only left in doubts if i will use openCV again or switch to Halcon.
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.