How to set startup executable for a VC++ project? - visual-studio

This is a pretty novice question, but I've been trying to build and run Ghostscript using Visual Studio 2012. When I try to do "Start Debugging" or "Start Without Debugging" the project builds fine, but then I get the error "Unable to start program 'C:...\ghostscript-9.07\debugobj\ghostscript.exe"
The project never outputs a ghostscript.exe file when compiled. It outputs "gswin32.exe" in the debugbuild directory, which is the file I need to run after compilation. I think Visual Studio is looking for debugobj\ghostscript.exe because the project is named "ghostscript" and debugobj is configured as the output directory.
Is there some kind of configuration setting I can set to specify that debugbuild\gswin32.exe is the executable that should be run after building?
Thanks.

Yes there is. From the Project menu go into Properties and review the settings in the Debug section.

Related

Debug command line arguments & working directory with linux remote debugging

I have a project that uses CMake, and I used Visual Studio 2022 to build it remotely on a Linux VM.
Now, when trying to debug, it starts up, but I can't find where is the option to specify the command line args and directory for the debugged process.
The documentation and examples I managed to find are only for vcxproj/sln built for Linux, but not for a CMake project. Some examples mention launch.vs.json, but I couldn't figure out to set it up for my case.
Where's that option?
In Visual Studio 2022, click DEBUG -> Debug and Launch Settings for [PROJECT_NAME]. This should open an editable launch.vs.json file (located in the .vs folder in your CMake root folder) that includes "args" and "cwd" keys.

CMake project target issue in Visual Studio 2017

I'm trying to run a cmake project (openmvg, for now) in Visual Studio 2017.
I believe I've installed it correctly following the instructions.
Now, when I try to run it (Release / Win32), I get the following error message:
"Unable to start program "D:\openMVG\build\Release\ALL_BUILD"
I've checked the CMakePredefinedTargets, but I can't find a project target except ALL_BUILD, INSTALL, and `ZERO_CHECK.
Can anyone help with this problem? I'll appreciate any answer to it. Thanks.
By default a newly generated MSVC project will always set "ALL_BUILD" as its Startup Project. To run the project you need you have to set it manually by clicking (right button) on the project and choosing "Set as StartUp Project".
CMake predefined targets are there for, well, predefined CMake targets. Those exist for rebuilding, test running, installing etc. Usually they aren't candidates to be startup projects but some of your projects are.

Visual Studio Can't debug CMake project - fails with "Unable to start program..."

When I create a project using Cmake, Visual Studio is unable to debug the application. It fails with the error:
Unable to start program '....PATHTOPROGRAM' Access is denied.
The project seems to build ok, just can't debug.
Projects created just with VS are fine
From my experience, CMake doesn't setup Debugging section of the generated project. I always had to do this manually. Fortunately, it is not that hard:
Choose any project you like, ALL_BUILD, for instance;
Open Properties -> Deugging;
Set Debug Target to the executable you want to debug from you build dir.
Even better, Visual Studio somehow keeps these settings even after CMake regenerate project files.

Execute exe file or bat file after compile with Visual Studio 2010

I would execute an exe file or a bat file after that the compilation of a C++ program ends. How could I do this?
EDIT 1
This is my actual command line:
start "C:\mypath\myexe.exe myarguments"
Check out the "Build Events" section in your C++ project's configuration properties. Here you can define commands to run before the project builds, before the linker runs, and after the project has built.
Check Post Build Event command line, in the Project properties.

Under vs10 msbuild.exe how can a specific project within a solution.sln be Ignored?

Under vs10 msbuild.exe how can a specific project within a solution.sln be Ignored?
I am building a large project that is moving to Visual Studio 10.0. In the IDE I can uncheck a project within the configuration manager and it will not build it. I need to mimic that behavior with a command line call to msbuild.exe.
The project I want to bypass is an *.dll plugin with a link error. I am stuck on stupid with the link error at the moment and since it stands alone, I can run the main program with out it and just live with a warning at run time that it isn't present.
I need some switch magic concerning calls to msbuild.exe.
If you have a certain configuration in the sln (configured in VS Configuration Manager) that you want to build with MSBuild, you can do so with the following command line:
msbuild /p:Configuration=MyConfiguration MySolution.sln

Resources