C++ Visual Studio 2010 "Unable to start Program" - c++

I've been looking arund and i can't find the problem for this. Whenever i try to debug my project, i get this error
Unable to start program 'C:/Users/.../project/.dll'
All i did was create a new application than put this
// This is the main DLL file.
#include "stdafx.h"
#include "asddsa.h"
/*
* File: main.cpp
* Author: Arhowk
*
* Created on March 22, 2013, 10:15 PM
*/
#include <cstdlib>
#include <iostream>
using namespace std;
/*
*
*/
using namespace std;
void main()
{
cout << "Hello World!" << endl;
cout << "Welcome to C++ Programming" << endl;
}
any help? I can provide more debug info if needed, but cant find any. Running VS2010 Express on a W7 x64 machine

You shoud create an exe project like "Win32 Console Application"
"C:/Users/.../project/.dll" looks wrong, Right click your project, select "Properties", check "General->TargetName", "Debugging->Command" and "Linker->General->Output File"

When you created your project, what type did you create? It looks like you created a DLL project. DLLs can't be ran directly, you need to have an exe that will load one or more DLLs.
If you create an exe project, you should be able to run it directly to test your code.

Related

How do I set up Visual Studio with default headers and comments?

I am fairly new to using Visual Studio. Currently I am using Visual Studio 2015 version. Currently when I set up a new C++ console application project (with Precompiled header off or on) it displays the following:
// Name of project.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
int main()
{
return 0;
}
Every time I create a new project I have to waste my time entering in my header information and comments. I would like it to look like this every time I create a new C++ console application project.
// *********************************************************************
// Name:
// Description:
// Date:
// Class Section:
// Title:
// *********************************************************************
//Heading information
#include <iostream>
#include "stdlib.h"
#include "stdafx.h"
using namespace std;
//Main function
int main()
{
//Pause system and end main function
system("pause");
return 0;
}
Is it possible to set up Visual Studio 2015 to display the code above every time I create a new project? Thanks
Create a new console application.
Edit the file to be as you want it in the new one.
Select "Export Template..." in the "File" menu.
Walk through the wizard (choose a name for your new template, etc.)
Be sure the "Automatically import the template into Visual Studio" is checked.
Restart VS
Select "New Project"
Select "Visual C++" in the tree control on the left
Select your new template in the list in the middle
The usual new-project stuff (name and location for the project, etc.)
[Note: As I'm writing this, I'm looking at it in VS 2013. I don't recall it's changing in VS 2015, but it's possible.]

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.

fatal error C1083: Cannot open include file: 'iostream': No such file or directory

I've reinstalled Visual Studio 2010 Professional several times to try to get it to work.
I had to uninstall Visual Studio 2012 Professional because it wasn't compiling something we did in class.
I completely uninstalled everything including SQL Server..
I went to VC/include and the iostream header file is not there.
#include <iostream>
int main () {
cout << "hello";
system ("PAUSE");
return 0;
}
This is all I'm trying to do because nothing else is working.
It's really driving me crazy because I need to get it working so that I can do my project!!!
Every time I do; new project => empty project => add an item to source =>.cpp
I'm running windows 8.
It just says Error cannot open source file
Also, error cout identifier is undefined....
I'm wondering if I should do a system restore?
Or if I should just completely reinstall windows 8 from my recovery media?
One problem is that you did not include the namespace std.
This is what your code should look like:
#include <iostream>
using namespace std;
int main (void) {
cout << "hello" << endl;
system("pause");
return 0;
}
or you could have done something like this: std::cout << "Hello" << std::endl;
This may be a problem because you did not set your environment to C++. This is how you do it:
Go to Tools > Import and Export settings. If you cannot find it, just search for it in Quick Search
Then go to reset all settings.
Then simply select "Visual C++"
Restart.
That should do the trick. If it does not, you might consider re-installing Visual C++ itself. For VS 2012. If that does not work, then re-install the program.
if it is problem with visual studio 2012, install this update.

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++).

Normal C++ code in Qt doesnt build and run

I am using Qt under linux, if it matters.
I ran successfully under Geany (a simple c++ compiler) the following:
//my first program in C++ Hello World!
#include <iostream>
using namespace std;
int main ()
{cout << "Hello World!";
return 0;}
I opened Qt source file and copied the exact same code and i can't build or run.
Thank you for your responses to this simple problem.
If you did what I think you did, you didn't open this as a project, which is the only place where you can build and run (I think).
Try the following.
- Open Qt Creator.
- Go to File->New File or Project
- At the bottom, select "Qt4 Console Application"
- Select a location; it might be nice to create a folder called "hello_world" or something to store the project in.
- A new project will have been created. Copy over the main.cpp file in sources with your code. My code looked like this:
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World!\n";
return 0;
}
Hit "Build All"
Hit "Run"
This worked for me. Hope this helps!