Unable to start program, cannot find the file specified, Visual Studio 11 - c

I'm working off of a fresh install of VS 11 Beta, on a Windows 7 64-bit machine. When I try to debug, it gives me this error message.
"Unable to start program 'C:\Users\myname\documents\Visual Studio 11\Projects\Project1\Debug\Project1.exe"
I'm almost entirely sure it isn't a problem with my code--it works fine on online compilers, making me think that it's an issue with how I'm saving it. Just in case, here it is.
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
printf("Hello, world!\n");
return 0;
}
My process for creating the project/file is to create a new empty Visual C++ project, then a .cpp file, write my code, save it as a .c inside of the first folder I'm prompted with, within the projects folder, and then try to debug.
What am I doing wrong, here? I know that the debug folder is empty, but I can't figure out how to create the .exe file that should reside in it.
NB: I'm rather new to programming. If answers could be phrased in babyspeak, that would be appreciated.

Well, there could be a number of things wrong. However, based on your description of making a ccp file and a c file, I'm betting that it's a problem in your VS 11 project rather than the code itself. My guess would be that either the c file didn't get included in your project (check the Solution Explorer) or that you have the main (or _tmain) function defined in both the cpp and the c files, which will make the linker issue an error.
There are a bunch of "Hello World" tutorials online for VS 2010 and earlier, but there don't seem to be many for VS 11 Beta yet. You may want to take a look at the 2010 versions. I found this video tutorial that you may want to check out.

Check the output directory. And you can also set manually an output direcotry to save the built exe file.

I know this problem was from May but I thought I would answer with a solution that worked for me:
I was creating a .cpp file in a blank project and was getting a similar error. I noticed that the file had a name but was not showing the extension .cpp. I added the extension to the file (ex3.18.cpp) and did not get the .exe error again.
I don't know if that makes sense with your issue but I worked on this for two days uninstalling and reinstalling VS 11, and this was what finally worked.

Related

VSCODE deletes my library line inclusion when saving automatically

I am programming C on VSCODE but I have this annoying problem. When vscode automatically saves my work, it deletes the line that has the library inclusion that I need. So when I compile it gives me an error that I did not specify the function. Someone can help me?
I don't know how to resolve.
You might have installed a corrupted version of vs code or the library files of the vs code and then location where you are saving your programs might be in different location. For example
The libary files of vs code might be in c drive and the program files might be in onedrive folder.
Try reinstalling it from an authentic source if the second stated problem is not the case. If the problem still continues then please comment down on my reply.
Reinstall either from microsoft store or from
https://code.visualstudio.com/download

code blocks error: no input files. C code

I just installed code blocks after I did format to my PC. currently, I work on windows 10 pro 64-bit and every time I open a project and run it I face an error it says as in the image; no input found.
I program C code on code blocks by GCC compiler.
I tried to search online but it isn't a popular problem and I hadn't found anything works.
I hope you can help guys and thank you in advance.
The problem happened because I named my Desktop directory in Arabic, which the compiler couldn't find the project file that I was working on.
So, in general, be sure of the names of the main directories on your PC that are written in the English language.

The system cannot find the file specified while programming C

Ok so I'm using Visual Studio 2017 on Windows 10. I'm wanting to use it to program in C. When I tried making a program, I got this one error "Unable to start program 'C:\Users\XXXX\source\repos\TestingProject\Debug\TestingProject.exe'. The system cannot find the file specified."
I looked around, and some people said it's due to faulty code that should bring up errors while compiling. There were a few issues, and I solved them to the best of my ability, but still can't get it to run. Since I can't figure out how to get Visual Studio to tell me specifically what's wrong (maybe if someone could tell me how I could get Visual Studio to say underline what piece of code doesn't make sense) I instead tried making and running a simple hello world program. However, I still got the error.
Here's the Hello World program code:
#include <stdio.h>
int main()
{
printf("Hello World! This is Just a test.");
return 0;
}
It still gives me that one error, and I don't know how to fix it. Also, if someone could tell me how to make Visual Studio do error checks while writing code, please tell me how. If anyone can help, I'd appreciate it.
It seems that the whole issue was down to the C file not actually being inside the project itself. This is quickly solved by looking at where the file is located by looking at the properties window, then locating the file, followed by copying the file and pasting it inside the "Solution Explorer" window.
Now, it actually shows me the error checks and what errors the code has. When I now create a "Hello World" program, it opens a separate window and prints out "Hello World!".
I must've thought that since I had the project open, and then opening a file from my desktop, that it could run perfectly fine. Just need to keep this in mind next time.
You can always try File -> Move .cpp into -> then select your project folder.
This worked for me.
You can always try File -> Move .cpp into -> then select your project folder.

Visual Studio (Visual Macro) doesn't include Arduino libraries

First, I'm sorry if it's not the proper place to ask this question. I'm not sure whether I should post it here or on Electronics Stack Exchange.
I use "Visual Micro" add-ons in Visual Studio 13 for Arduino. Normally, it works fine. But for my project I had to download these two library files, "Adafruit_SSD1306" and "Adafruit_GFX". Arduino IDE works fine but Visual Studio can't include them. It can't even include "Wire.h" but perfectly includes "SPI.h" header where both of them are in same directory. I included those files directories in project properties. But when I run "Build" it gives a fatal error:
And stops compilation. Same error occurs for the remaining two include files.
Can any one point out any mistakes I made, or suggest any way to solve this problem?
Thanks for your time.
Screenshot of project properties:
Actually I made a very silly mistake that most of the time is not worth to look for. This is just crap.
There is no space between "#include" and <Wire.h> and so the compiler is reading this as a whole sentence. If I write:
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
instead of
#include<Wire.h>
#include<Adafruit_GFX.h>
#include<Adafruit_SSD1306.h>
Then everything is fine.
How silly I am. -_-

How do I debug existing C programs with Visual Studio 2010 Professional?

how can I use the Visual Studio Debugger on existing C programs I found in a textbook? I want to debug these little examples one by one, but without the overhead of creating a full project for each example.
Example: Let's say I compile "helloworld.c" from the Visual Studio command prompt ("cl.exe helloworld.c"). This gives me helloworld.obj and helloworld.exe. I would like to know if there is a way to use the VS debugger on "helloworld.exe". So far, I have only worked with the debugger on full-blown projects; I have no idea how to debug small "stand-alone" test programs without the Visual Studio project overhead. (I hope this is not a dumb question, as the VS Debugger might only be available for the full project.)
Thank you for any ideas.
Why don't you create one project for testing the sample codes? You can create a single .c-file for all the samples. This would look something like
void sampleA()
{
//hello world
}
void sampleB()
{
//hello everybody else
}
void main(int argc, char** argv)
{
// sampleA();
sampleB();
}
What I do when I have to use VS is to reuse the plain.c project I created a long time ago.
Just paste new code there and go. Throw the code in another file if you want to keep it.
If you're set on not using projects then you can do this. It just gets more difficult as the number of code files increases.
First, to do any meaningful source-level debugging, you will need to generate debug symbols. Add the "/Zi" switch to your cl.exe command line:
cl.exe /Zi helloworld.c
This will generate helloworld.exe, helloworld.obj, and helloworld.pdb (these are the debugging symbols).
Next you will open Visual Studio 2010. Use File -> Open -> File... and select helloworld.exe. It will generate a wrapping solution with one project for your EXE file.
In Solution Explorer, right click on the EXE file and select Debug -> Step Into new instance.
It should pop up a source window and show you the first line of your program. Now, debug away!
The debugger is part of Visual Studio, so you'll have to start it up anyway. However, for the debugger to work properly with your source code, you need to also generate a PDB file (see here). You get this by including /Zi or /ZI as argument to cl.exe (see here).
It is not impossible, but you'll have to learn a lot more about how to exactly build a program from the command line to get the best debugging experience. There are a bunch of options that are real time savers and greatly improve the odds that you'll discover bugs.
Which is a little beside the point right now, learn C instead of spending time learning a boring tool with way too many options. Creating a new project takes 5 seconds after a wee bit of practice. Use the Win32 Console Application project template.
One small setting you have to change if you want to compile as C instead of C++. Right-click the project, Properties, C/C++, Advanced, Compile As = Compile as C Code.
The "overhead" is hardly more effort that it took to post this question!
Simply start with the "Empty Project" template and add the single source file you wish to debug by right-clicking on the project browser sources folder. It takes mere seconds.

Resources