Over 400 errors when using Visual Studio C++ - c++

I am working on some coursework and the code works perfectly fine on the university system but when I transfer the exact same code to my own PC, I get over 400 error messages. These consist of:
Cannot open source file "name.h"
The global scope has no "name"
identifier "name" is undefined
explicit type is missing ('int' assumed)
A full list is here https://pastebin.com/CRJd7hAp
I get these errors on all of my code, even something as simple as a Hello World program
#include <iostream>
using namespace std;
int main()
{
cout << "Hello world! " << endl;
system("pause");
return 0;
}
I am at a loss as for what to do.

I reinstalled Visual Studio and set the SDK from 8.1 to the newest release. Everything is working fine now. Thank you

Related

C++ Hello world keeps giving me errors in Visual Studio 2019

I'm just trying to print hello world using C++ but all I get is build errors. The error list shows 412 errors and they're mostly "Cannot open source file" followed by a file name that I haven't heard of.
It also says the WindowsSDKDir property is not defined and the solution I found was to repair visual studio when I looked up this problem. I completed repairing visual studio and I have the C++ selected in the workloads.
Even when I select "Console App" during initial set up it'll end up giving me the same errors even though that is supposed to set up a basic environment for Hello World.
My code is simply just to print out hello world.
#include <iostream>
void output();
int main()
{
output();
}
void output()
{
std::cout << "Hello World!" << std::endl;
}
So I just uninstalled Visual Studio completely and then reinstalled it. I realized I could have just modified it using the installer, but basically after selecting the C++ workload I made sure every box was selected on the right hand side. I don't know if I needed it all but I just installed everything to be sure and it finally worked.

Errors in C++ Hello World program

Installed c++ in visual studio 2019 some time ago and it worked perfectly. Today when I launched I got 490 errors. This is a screenshot of what a Hello World looks like: https://imgur.com/yxIs9Np
I am completely new to c++ so I dont know whats wrong, I have tried to search for the error but I could not find anything. I have tried to reinstall c++ in vs and updated vs to the newest version.
code:
#include <iostream>
int main() {
std::cout << "Hello World!\n";
}
its nothing wrong with the code, I think something is wrong with the librarys. For some reason I get 17 errors " cannot open file "[Some name].h" "
Reinstalled visual studio, this worked. The problem was that it dident include C:\Program Files (x86)\Windows Kits\10

Run C++ program in Terminal

I'm trying to run this simple C++ code in Sublime Text on Terminal but it's not exactly working...
#include <iostream>
using namespace std;
int main() {
cout << "Hello world!" << endl;
return 0;
}
I'm getting this message instead:
"hello_world2.cpp:1:10: fatal error: 'iostream' file not found"
How can I fix this?
You most probably are missing development headers for your C++ standard library.
You didn't say anything about your environment, but if you were on Windows on Mac you would for sure get these together with your compiler, so let's assume Linux.
You need to install libstdc++-devel package or equivalent (libstdc++-4.8-dev etc.)

Required file "tracker.exe" is missing

First time using Visual C++ in Visual Studio and I'm trying to teach myself C++ from some books. I am just trying to do a basic "Hello World" program and its getting a couple errors that I don't know anything about, as well as a bizarre warning. The missing source file seems to be standard and I can't figure it out.
The errors:
Error 2 error : Required file "tracker.exe" is missing.
Error 3 IntelliSense: cannot open source file "SDKDDKVer.h"
The warning:
warning MSB8003: Could not find WindowsSDKDir variable from the registry. TargetFrameworkVersion or PlatformToolset may be set to an invalid version number.
The code:
#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World!" ;
// This prevents the Console Window from closing during debug mode
cin.ignore(cin.rdbuf()->in_avail());
cout << "\nPress only the 'Enter' key to exit program: ";
cin.get();
return 0;
}
Any explanations or help would be huge! Thanks.
Here's a standard C++03 "hello, world!":
#include <iostream>
using namespace std;
int main()
{
cout << "Hello, world!" << endl;
}
Turn off precompiled headers in the project settings. Make that compile without adding anything. Run it via Ctrl F5 (alternatively place a breakpoint on the final } and run it via the debugger, e.g. keypress F5).
If that doesn't work then you have configuration error. Then try first a new project. If that doesn't work, uninstall VS and reinstall it.

visual studio 2012 c++ hello world - iostream not working

I have an issue with Visual Studio's 2012. I am also using "Sams Teach Yourself C++ in One Hour a day, 7th edition".
After using google to find the "best" compilers for C++, Visual Studios seemed to be the tool of choice.
So I downloaded and installed Visual Studios 2012. The very first lesson in the book is (and tells me to run it as a console app by going to File > New > Project >Visual C++ > Win32 > Console Application )
#include <iostream>
int main()
{
std::cout << “Hello World!” << std::endl;
return 0;
}
which doesnt work, at all. it outputs an error message similiar to the following:
1>c:\users\nik\documents\visual studio
2012\projects\consoleapplication4\consoleapplication4\consoleapplication4.cpp(8):
error C2065: '“Hello' : undeclared identifier
1> Generating Code...
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped =========="
(there is more lines similiar to the first, but its rather long)
However, after googling and watching a video on youtube the following code works (using File > New > Project >Visual C++ > General > Empty Project )
#include <iostream>
#include "conio.h"
using namespace std;
int main() {
cout << "Hello Nik" << endl;
_getch();
return 0;
}
Does Visual Studio's 2012 have a C++ compiler? or does it just have a visual c++ compiler (if thats even the issue, only reason I think it could be is I can see templates for Visual C++ but none for c++ by itself...) or do I need to download Visual Studio Express to download native c++ ??
Any help would be greatly appreciated as I am feeling some-what out of my depth here...
Thanks.
Besides aphostrophes you may need to disable precompiler headers in project properties.
They are turned on by default in VS2012. If you are not familiar with precompiled headers turn them off.
Right click on project (not solution)
Click properties.
Expand "Configuration properties"
Expand "C/C++"
Choose "Precompiled headers"
Set "Precompiled header" to "Not Using Precompiled Headers"
More information about precompiled headers and stdafx.h file at Wikipedia
The apostrophes you used are wrong:
“Hello World!”
should be
"Hello World!"
Notice even how SO recognizes the difference. You should at least type the code you see in the book instead of copying and pasting it. ;-)
The Win32 console application is actually quite different from the empty project. Win32 utilize a message (input) queue which you poll in a loop and your program respectively utilizes the Win32 API and performs certain operations.
The empty project is a bit less dependent on Win32 or anything that Windows provides in terms of API unless you make it dependent on it. This would be the simples hello world app in you empty project:
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World" << endl;
return 0;
}
Just try this::
"Hello World!" instead of “Hello World!”.
The difference between
“Hello World!” and
"Hello Nik" is the apostrophe.
Aslo is the error persists than just check visual c++ library linker.
There is aslo definitely no need for conio.h
If your going to copy from a book at least copy it correctly.
Using namespace std;
would be pretty smart in this case.
In order to fix your error you have to delete std:: of std::cout and std::endl, and write using namespace std; underneath #include iostream and and change “ ” with " ".
#include <iostream>
using namespace std;
int main()
{
cout <<"Hello World" << endl;
return 0;
}
In Visual studio 2012
file>new projet>visual c++ (Project win32)>application settings(application console+Not Using Precompiled)>in right box in you Project (right click, add>new element>file c++).