Trouble Creating a Linux Console Application in Visual Studio - c++

I am trying to create a C++ Linux Console Application in Visual Studio, but so far it is behaving strangely. Upon creation, I get the following warning/error messages:
warning : Platform '[ARM64, 0]' referenced in the project file 'ConsoleApplication4' cannot be found.
warning : Platform '[ARM, 0]' referenced in the project file 'ConsoleApplication4' cannot be found.
warning : Platform '[x64, 0]' referenced in the project file 'ConsoleApplication4' cannot be found.
warning : Platform '[x86, 0]' referenced in the project file 'ConsoleApplication4' cannot be found.
error : Designtime build failed for project '' configuration 'Debug|x64'. IntelliSense might be unavailable.
Check *.designtime.log files in your %TEMP% directory.
When I check the log file in my %TEMP% directory, I see the following errors:
error MSB4057: The target "GetClCommandLines" does not exist in the project.
error MSB4057: The target "GetProjectDirectories" does not exist in the project.
I've seen some other questions with similar error messages that involve changing project properties, but when I right-click on the project in Visual Studio and click Properties, I get a popup window saying there are no property pages for the selection.
I have also seen questions that discuss making edits to the .csproj file, but my project only contains a .vcxproj file (I suspect because this is a Linux project?). Additionally, I would expect to see "(Linux)" after my project name in my Solution explorer, but it is not there. The Solution explorer also does not list the main.cpp file under the project, despite the fact that it is present on disk in the project's directory (code-wise, it contains the default printf statement inside a main function, with an include for cstudio). It's almost like Visual Studio doesn't recognize the project as a Linux Console application, but I'm not sure how to make it recognizable.
I have tried this on Visual Studio 2017 and Visual Studio 2019. I have used the Visual Studio Installer program to ensure that the following workloads are installed:
Visual Studio core editor
.NET desktop development
Desktop development with C++
Linux development with C++
I have tried repairing each installation as well as a full uninstall/reinstall. I have also enabled Windows Subsystem for Linux, installed the latest .NET developer tools, and have PowerShell installed on my system. What am I missing?

Related

MyProject.dll is not a valid win32 application

I have copied a C++ solution folder written with visual studio 2013 to my Pc and tried to run it (I mean VS Debugging) with VS 2022. the solution Contains 5 projects but I just target one of them so unloaded the rest and set the one as Startup project and this error happened.
Error Image
Solution file is working well on first pc and project is not a win32 project its x64 (I don't know much from win32 or x64).
Unable to start program. [VALUE].dll is not a valid Win32 application error in Visual Studio 2017
According to this question I tried selecting project, setting as startup, repairing VS, installing vcredist_x64 but non helped.
After Running, VS make Debug folder in solution Directory not the project "LP_Dll\x64\Debug" (LP_Dll is the solution name) without any .exe file, and the error path is exactly this folder, can it be from that?
Project properties the "Configuration Type" was mistakenly changed to .dll.

I just installed visual studio and ran into some errors specifically The WindowsSDKDir property is not defined. Some build tools may not be found

Just installed visual studio 2019 on windows 10, was using visual studio for the first time and ran into the following error, It's a basic hello world console program that I tried to run.
error C1083: Cannot open include file: 'corecrt.h': No such file or directory
1>Done building project "ConsoleApplication2.vcxproj" -- FAILED.
Severity Code Description Project File Line Suppression State
Warning MSB8003 The WindowsSDKDir property is not defined. Some build tools may not be found. ConsoleApplication2 C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets 434
I tried searching for this error over YouTube and of course here, and also Microsoft's offical forum but couldn't find anything.
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World!\n";
}
the code looks just fine.
I ran into the same issue today. It turns out I didn't check the Win10SDK to save disk space while installation.
Solution:
In VS, go Tools menu=>Get Tools and Features=>install the Windows 10 SDK(10.XX.XX.XX)
Once installed, launch VS and open your project, right-click your project(NOT Solution)->properties->General->Windows SDK Version, check the value should be 10.0 instead of blank.
Then the compiling just worked.
I've got the same issue and turned out that I haven't installed Windows SDK. It can be done by typing "Install Windows SDK" into visual studio's search prompt
I had same problem when I installed Visual Studio 2019 on Windows7 and opened project created in Visual Studio 2017 (witch wasn't installed on that machine).
To solve the problem I went to project Properties -> General -> Windows SDK Version
And changed it from 10 to 8.1.
I fixed this issue by repairing Windows SDK. Now it's working as expected.
Steps:
Go to Settings>Apps & Features.
Click on Windows Software Development Kit - Windows 10.0.18362.1
(Note: Version number might be different for you)
Click on Modify.
Select Repair from options.
Click Next.
Restart VS and try running your project.
I was just having thesame issue so I figured maybe the headers were in a different directory than where the program is searching. When I went looking for tge header files none existed. So the problem is probably with iostream not existing.

Adding Icon to QT5 causes linker error

I've been struggling with adding an icon to my QT application. Now the problem is not getting it to work in the application itself (the icon shows fine in both the taskbar and in the upper left of the application window). The issue is with the windows explorer.
Now I found a few solutions which state to either add an .rc file to the .pro file or to use RC_ICONS.
But both of these implementations result in a linker error:
LNK1123: failure during conversion to COFF: file invalid or corrupt
Doing some search onto that only resulted in finding people that try to compile without having VS2010 installed, but that's not the case here since it is installed and compiles fine without the icon.
Any suggestions would be appreciated.
The following solution worked for me with both Visual C++ 2013 and MinGW but this is Windows-specific.
Add the following line to your Qt project file.
RC_FILE = WindowsResource.rc
Now create a text file in the same folder as your Qt project file and call it WindowsResource.rc, you can call it whatever you want as long as it is referenced correctly in the Qt project file. Open it in Notepad and insert the following line.
IDI_ICON1 ICON DISCARDABLE "MyIcon.ico"
Now place the icon you want in the same folder as your Qt project file and call it MyIcon.ico, you can call it whatever you want as long as it is referenced correctly in the windows resource file you created.
Run qmake and rebuild your application, the .exe file should now show up in Windows Explorer with the new icon.
Edit:
I used Visual C++ 2013 and it worked. I quote the article at http://support.microsoft.com/kb/2757355
Cause: This error can appear after installing Visual Studio 2012 side-by-side (SXS) with Visual Studio 2010 RTM or after installing .Net Framework 4.5 on a machine with Visual Studio 2010.
Resolution: To resolve this link error, upgrade Visual Studio 2010 RTM to VS 2010 SP1. Upgrading to VS 2010 SP1 resolves the dependency failure and the VC++ 2010 project builds with no LNK1123 error.
If you are using Visual C++ 2010 then I suggest that you make sure you have Service Pack 1 installed, I'm not sure that installing SP1 would solve the issue though because you were compiling fine without the icon.

Visual Studio Express 2013 freezes when opening project properties

Main Problem
When I try to access the properties of a project in Visual Studio Express 2013 for Windows Desktop through Project -> ProjectName Properties, Visual Studio freezes completely without an error and I must end it through the Windows Task Manager.
I ran Visual Studio with /safemode enabled. This did provide some information by saying that "The 'Visual Studio Component Model Host Package' package did not load correctly."
It also produced a log file with some errors and warnings. Errors and warning entries in the log can be searched for with <type>Error</type> and <type>Warning</type> respectively. Additionally, opening the file in Internet Explorer seems to apply some styles to the file and makes it more readable.
Errors only - http://pastebin.com/295sX8kH
Full log - http://pastebin.com/KGspUgGs
The errors in the log seem to center around this Visual Studio Component Model Host Package. I tried searching for errors related to that, but did not find anything I thought was applicable to my situation.
The dll Microsoft.VisualStudio.ComponentModelHost.Implementation.dll is present in C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\PrivateAssemblies\
The dll Microsoft.Data.Entity.Design.DataSourceWizardExtension.dll is indeed missing from C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions\DataDesign
Extra Info
I am using version 12.0.30723.00 Update 3 of Visual Studio and I am running Windows 7 Professional 64-bit 6.1 build 7601.
I have tried re-installing Visual Studio in order to to clear out any bad settings, but that did not seem to work.
I tried running Visual Studio with /resetskipkgs and /resetsettings, and neither of those worked.
Trying to open project properties in safe mode still froze Visual Studio.
Backstory
I am ultimately trying to setup an environment in which to develop OpenGL applications. I have some experience with it through following the Arc Synthesis tutorials, but I do not know how to operate outside of the specialized environment the tutorials provided.
Following the OpenGL Book setup instructions, I am told development will go more smoothly if I use the GLEW and freeGLUT libraries. In order to do so, I need to be able to link in extra files to a project. In Visual Studio, this is done through the project properties dialog, but I cannot access it due to the freezing problem.
I am not very familiar with the development process in C++, so I am wary of venturing outside of the IDE provided by Visual Studio, but I might just have to do that if this problem persists.

Extend the Visual Studio C++ Build Process

A found an article (Extend the Visual Studio Build Process) that explained how to override build targets in a C# project file. I tested this, and it seems to work well. However, what I really want to do is override a build target in a C++ project (with Visual Studio 2005). The problem is that C++ projects use different XML. Instead of having <project> as the root, C++ projects have <VisualStudioProject> as the root. When I add the <target> tag to a C++ project file and try to open the project in Visual Studio, I get this error:
The following error has occurred during XML parsing:
File:
[Path to Project File].vcproj
Line: 304 Column: 30 Error Message:
Element 'Target' is unexpected
according to content model of parent
element 'VisualStudioProject'.
The file
'[Path to Project File].vcproj'
has failed to load.
How can I override a Visual Studio build target for a C++ project? Or is there a better way to customize what happens during a C++ build?
In Visual Studio 2005 there are no build "targets" for C++ builds as the C++ build system does not use MSBuild.
However, VC++2005 defines the Pre-Build, Pre-Link, Post-Build Events as well as the ability to add a Custom Build Step for non-standard files.
You may be able to achieve what you want using these settings.
Note:
VC++2005 projects can be built using MSBuild, it's just not what Visual Studio does out of the box.
Visual Studio 2010 uses MSBuild for all project types.