I had an old project I was working on previously, just to keep it simple let's say the project is a calculator.
Today, I opened Visual Studio, selected a new project, and add a source file helloworld.c. If I leave the whole file empty and press f5 (start debugging), it gives me the error there is no entry point, which is expected.
However, once I add in the code for helloworld.c and try to start debugging, I get an error about multiple instance of "main". So then I remove the main from helloworld.c and try pressing start debugging again, and now for some reason it runs my calculator program. I have no idea why is this is happening. I don't have the old program running at all and I haven't touched it, how can I stop Visual Studio from running this project??
Thanks
Edit: seems like this only happens when I have "#include <'winsock2.h>", but im not sure why this would be related... (ignore the ')
Related
I'm working with simple c/c++ console projects in Visual Studio 2017.
After a build, if I run/debug it from within the IDE (Ctrl+F5 or F5), there's always a strange wait of tens of seconds before it actually runs (e.g. if I printf on the first line of my main(), it won't show until after the long "wait")
If there's no build after this first run, and I Ctrl+F5 or F5 again, it runs fast and normal. If then I change some source code and rebuild it, the strange wait appears again.
This slows down the dev iterations so much, and definitely feels wrong. Just wonder if any guru here can point me to a solution/workaround?
Thanks in advanceļ¼
OK, mystery resolved -- it's my Avira antivirus. Somehow after installing VS2017, it starts to scan each new exe I generated. After setting my dev folders as exceptions, things are a lot quicker. Finally.
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.
So, the problem that I am having is that when I push F5, or click Start, Visual Studio starts debugging, but the application doesn't actually build. If I go to my Task Manager, and look for the process it isn't there. Or, if I alt-tab between the programs I had open. I have had this problem twice now. The last projet I started, I encountered this problem. I spent days looking for answers on my time off but couldn't find anyhting. So i started a new project. And now I'm getting the same thing. If I go to my source tree and go back to a previous build and discard my changes, it works fine. But the problem comes back. Its not my coding. I am not getting any build errors. And I don't have any break points. So i can't hit continue. PLease alos note, that between it working, and not working I have not changed ANY setings in Visual Studio. I will post what I have tried. If I forget anything, please forgive me. I have days and days of history to go through in my browser.
Restarted Computer and VS
Ran VS in Admin
Always Build is selected in Tools -> Options -> Projects and
Solutions -> Build and Run
Make sure project is set to Debug in Solution Configuration and
Build is checked in Configuration Manager.
Make sure Only BUild startup projects and dependencies on run is
unchecked
Clean Solution
Unchecked Enable the Visual Studio hosting process in Project ->
Properties -> Debug tab
Made sure vshost32.exe was not running in the background while
program was not running in the Task Manager.
Deleted contents of bin and obj files in my project folder file and
reset computer.
Tried running the program from the exe in previously mentioned
bin/obj file. (The last one does start the process in Task Manager. But still doesnt show in the task bar, or alt tab.)
None of these have worked. I am getting very frustrated at this. Maybe I am not looking for the right thing in Google...
I suggest you close all third party tools/processes like the Anti-virus or others, and then re-debug it.
Or
You could run your VS in safemode:
devenv /SafeMode
Some community members found that the symbols loaded is really slow recently, and this issue has been report the Microsoft product team, so please also disable the Microsoft symbols server under TOOLS->Options->Debugging->Symbols. Debug it again.
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.
I made some changes in a WPF xBap application and it compiles well but the new changes is not applied and when I put a break-point on the changed lines, the IDE ignores the break-point and shoes the following hint message: "The breakpoint will not currently be hit, No executable code associated with this line."
I tried the following:
Cleaned and Rebuilt the Solution
Cleaned the cache
Restart the machine
and no hope.
Any idea or suggestion will be appreciated.
Note: The application works well with the new changes in the published version but it does not through the IDE.
"No executable code associated with this line"
try to add a debug line Console.WriteLine() and add a break point at that line.
I found the problem, it's because a wrong path in the file projectName.csproj.user.
I opened the file using the notepad and edited it manually.