CMake project target issue in Visual Studio 2017 - visual-studio

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.

Related

Unable to build a freshly created Xamarin Cross-Platform project with MsBuild

Here the repro steps:
Start VS 2017
Create a cross-platform project ==> Sample.sln
Build it in VS ==> Ok
By building with it with the command "msbuild Sample.sln" I get 4 times the following error message: error MSB4066: The attribute "Version" in element "PackageReference" is unrecognized.
Anything missing in the .csproj files I am supposed to add?
Thanks in advance for your support.
Make sure that you use the path to msbuild.exe that is installed with Visual Studio. Use the Developer Command Prompt for Visual Studio 2017 if unsure, it has the PATH set up so that msbuild will point to the right executable.
This error happy when you use an old version of MSBuild (e.g. the version included in .NET Framework) that doesn't support the necessary features - metadata as attributes in this case.

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.

FreeGLUT 3.0.0 Visual Studio solution?

Where is the Visual Studio solution for FreeGLUT 3.0.0? I know the 2.8.1 has one, but 3.0.0 does not. I would really like to use the latest version.
Use the included CMakeLists.txt to create a Visual Studio solution:
How to build freeglut with CMake on Windows (MS Visual Studio)
Download CMake (http://www.cmake.org/cmake/resources/software.html).
Get one of the releases from the binary distribution section.
Run the CMake installer, install wherever you like.
Launch CMake via Start > Program Files > CMake 2.8 > CMake (GUI)
(note that the shortcut put by the installer on your desktop does NOT
point to the CMake GUI program!)
In the "Where is the source code" box, type or browse to the root
directory of your freeglut source (so that's /freeglut, not
/freeglut/src).
In the "Where to build the binaries" box, type or browse to any
folder you like - this will be where the Visual Studio solution will be
generated. This folder does not have to exist yet.
Hit the Configure button near the bottom of the window.
Pick your target compiler, make sure that its installed on your
system of course!
Answer Ok when asked if you want to create the build directory.
Wait for the configure process to finish.
The screen will now have some configuration options on it, for
instance specifying whether you want to build static and/or shared
libraries (see below for a complete list). When you've selected your
options, click the Configure button again.
The Generate button at the bottom will now be enabled. Click Generate.
The build files will now be generated in the location you picked.
You can now navigate to the build directory you specified in step 5.
Open the freeglut.sln file that was generated in your build directory,
and compile as usual

Static build of Assimp using Cmake & VS2013: cannot find assimpd.pdb

I am trying to statically build Assimp on Windows to later make a standalone executable. Here is what I did:
I downloaded the 3.1.1 version and used Cmake GUI.
I unchecked BUILD_SHARED_LIBS and checked ASSIMP_BUILD_STATIC_LIB
Clicked on configure and Generate
Opened the solution with Visual Studio 2013 in administrator mode
Right cliked on ALL_BUILD and build
At this point everything worked fine. Then I tried to build INSTALL (right click > build) and it failed with:
file INSTALL cannot find
"C:/Users/.../assimp-3.1.1/build/code/Debug/assimpd.pdb"
I have two questions:
Should I actually build INSTALL as I only want a static build?
If yes, what did I do wrong/what should I do to fix this?
Thank you very much for your time!
PS: I checked the directory Debug and there is only a assimpd.lib

How to set startup executable for a VC++ project?

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.

Resources