Programs Will Not Run In Visual Studio - c++

My programs will not run in VS. I can code it, but it will not debug or start. It says:
Unable to start program 'C:\Users\Bob\Documents\Visual Studio 2013\Projects\Crankexe2\Debug\Crankexe2.exe'. The system cannot find the file specified.
This goes for all other programs as well.
What is happening?

Why do you open exe file using VS? if you want to open project, please choose sln file. If you want to run this, shortcut ctrl+f5 or using window explorer go to path "C:\Users\Bob\Documents\Visual Studio 2013\Projects\Crankexe2\Debug\" and open file "Crankexe2.exe"

Related

How to run C/C++ code using integrated terminal in Visual Studio

How to launch a C/C++ console application using the integrated terminal in Visual Studio instead of launching a separate terminal window?
To clarify more:
When I press the run button right now, this is what happens:
But what I want is something like this (but it must happen when I press the run button), where the output is directed to a terminal inside the visual studio window, without launching a separate window, this will make it easier when debugging because I won't have to switch between multiple windows:
There is a handy VsConsoleOutput extension for Visual Studio 2019 / 2022 that redirects program output into Output window inside of Visual Studio.
However when installing it i've got an exception complaining about incorrect value of InstalledByMsi value somewhere in manifest. The workaround is to manually open downloaded .vsix package (which seems to be a .zip archive) using WinRAR or something, adjust one line in extension.vsixmanifest file and save updated archive.
<Installation AllUsers="true" InstalledByMsi="false">

How to compile a C++ File without making a project in Visual Studio 2017?

I want to compile a C++ source file without making a project in visual studio 2017 without making a project like we do in some code editors, how can I do that. Can anyone please tell?
Here is an example, in sublime text, I create a code and then compile it by ctrl + b.In a similar manner, I want to do that in visual studio 2017.
You can open a folder and start coding in visual studio without creating a project or solution file.
They call it the Open Folder feature.
Visual Studio 2017 introduces the "Open Folder" feature, which enables you to open a folder of source files and immediately start coding with support for IntelliSense, browsing, refactoring, debugging, and so on. No .sln or .vcxproj files are loaded...
from the main menu select File | Open | Folder or press Ctrl + Shift + Alt + O.
The easiest way I found from there is to right click in the "Solution Explorer" area and select "Open Developer Command Prompt". From there you can use cl to compile your program however you see fit.
You can open "Developer Command Prompt for VS2017" at the start menu and use cl.exe to compile your source code.
E.g.
c++ source file name: test.cpp
type "cl test.cpp"
Then, it will generate "test.obj" and "test.exe" if no bugs found.
You can type "cl" for simple usage and "cl /?" for complete help.
If you wish to get away from the IDEs I would recommend looking up MinGW for compiling in the command prompt. If you are running Ubuntu or something similar I believe you can compile in bash without further extensions.
For MinGW http://www.mingw.org/wiki/mingw_for_first_time_users_howto
I believe you compile in the same way in ubuntu if not I believe you can find some sources for that aswell.
Pros about compiling in the terminal is mostly that you do not have to setup a complete project but you can make your own personal little setup. Of course an IDE is a simple way to start but compiling in the terminal also helps you understand what is actually happening instead of just pressing "Debug".

OpenCV cannot open video file when run with Visual Studio 2015

I want to open a video file in my OpenCV C++ application with
cap.open("../../data/Example.MP4");
but somehow when I run the application in Visual Studio 2015 (I've tried both Debug & Release mode), it cannot find the file.
Surprisingly if I run the application by just double clicking the .exe in Windows Explorer, everything works fine and the video file opens as desired.
Does somebody know why Visual Studio cannot find the file?
Thanks a lot!
The problem is related to the Project's Working directory, on Visual Studio. From inside it, it isn't finding the file...
Go to Project Properties, Debugging. There you will see, by default, that the Working directory is your project directory. Change it to $(OutDir) and your path should be fixed.

Visual Studio 2012 does not generate exe

I've a C++ project in Visual Studio 2012 Express, and I started having problems lately. When I compile the project it works, nothing wrong, however when I try to execute it the .exe disappears. I mean, I compile the project, the project generates the exe file with no problems, but if I try to execute it from Visual Studio or directly from the output directory, Windows say to me:
Cannot start the program 'C:\Users\Adrian\Dropbox\MyApp\Debug\MyApp.exe'.
The system can not find the file specified
If I create another project, Hello World for example, there is no problem and the exe generates and executes good. So I guess the problem is specific to my project. I tried disabling Avast (because maybe he delete the file) and the problem persists.
Also I create another project, including the files and... the problem is still here...
I check the project options, specifically general and debug options and I see nothing wrong.
So does anyone have an idea what may be wrong?
The output directory is $(SolutionDir)$(Configuration)\ and I'm compiling in Debug mode.
The windows error message is misleading. It should state that, loading a library (dll) failed. You might run the program with a process monitor (see: http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx)

Visual Studio 2010 C++ native debug mode resources

I am very desperate now...
I have project in Visual C++ 2010 using Qt and OpenCV. I got to phase I need to load XML file using openCV. But, I have no idea where is the working directory of my project, when run thru VS (F5). I mean, I read all config, copied desired file almost everywhere in my project folders, but it still is not seen by my EXE (OpenCV)...
What Am I doing wrong? Thanks.
right click on your project click on properties/Configuration Properties/debugging you start in whatever working directory is set to.