cannot open source file "afxwin.h"/"afxext.h"/"afxdisp.h"/"afxdtctl.h"/"afxcmn.h"/afxdisp.h etc - c++

I try to ran a previous written MFC c++ code on my visual studio 2015 MFC with multitype MFC library installed.
However, I still have 12 errors here regarding missing function:
IntelliSense: cannot open source file "afxwin.h"
C1083 Cannot open include file: 'afxwin.h': No such file or directory
cannot open source file "afxext.h"/"afxdisp.h"/"afxdtctl.h"/"afxcmn.h"/afxdisp.h etc....
Where can I get these head files?
Again, my set up is:
VIsual studio 2015 ultimate MFC
Multibyte MFC library installed
Windows 8 - 64 bit machine
Thanks!

I just fixed a similar problem. Here's how you can resolve this.
Go to your control panel
Navigate to uninstall/change a program.
Scroll down until you see your visual studio installation
Click change
Once the window pops up, click "Modify"
Under Programming Languages -> Visual C++
Make sure "Microsoft Foundation Classes for C++" is checked. If it isn't select it and click update.

For VS2019 the above solutions didn't worked for me.
I had to go to "Installer -> Individual Components -> "
and install the following to solve the issue:
"MSVC v141 – VS 2017 C++ x64/x86 build tools (v14.16)"
"C++ MFC for v141 build tools (x86 & x64)"
"C++ ATL for v141 build tools (x86 & x64)"

For what it's worth. I was getting similar errors after a fresh installation of VS2017. I installed the C++ features from the main installer and created a new project with MFC checked. I assumed "Microsoft Foundation Classes for C++" was installed by this point, but I kept getting these errors. Furthermore, after saving and closing the solution for the first time, VS wouldn't load the project if I opened the solution from the recently used list because dependencies were missing.
What worked for me
I opened the solution file directly using VS2017. Finally, VS informed me that "Microsoft Foundation Classes for C++" was not installed and gave me the option to install it. I had previously looked through the installer features and could not find this option.
EDIT
Per Vladimir's comment below...
In 2017 Visual Studio Installer it ["Microsoft Foundation Classes for C++"] is under Modify / Individual Components / SDKs... / MFC and ATL support (x86 and x64)

Related

Qt VS Tools: error reading VS project settings

I develop an application using Visual Studio 2015 + Qt VS Tools extension. For me it's first time I used Qt (version 5.14.1) in my project. Everything was working fine until something wrong happened.
I was asked to make release version of my application, it worked fine on Windows 10 and Windows 7 64-bit systems. Then I set the project configuration back to Debug x64 to continue my work. First strange thing I noticed - when I double-clicked on *.ui form files in my Solution Explorer, Visual Studio crashed and reloaded without any error, Qt Designer doesn't launch.
What I tried:
First I tried to open Qt Designer externally (from bin folder in Qt directory) and open my form - it worked.
I tried another project made in VS 2015 + Qt VS Tools Extension - same problem.
I tried to remove my Qt Version and re-add it. And here it comes: Error screenshot. It also occurs without using system enviroment variable $(QTDIR).
I reinstalled Qt to my PC (installed version 5.14.2 instead of 5.14.1), same error.
I reinstalled Visual Studio 2015, same error.
I tried to reset my Visual Studio settings and parameters to default, no results.
I installed Visual Studio 2019. The problem is still present.
UPD:
I cleared Visual Studio cache according to these instructions. It didn't work for me.
I removed every Visual C++ Redistributables from my PC and installed the latest version from Microsoft site. It also didn't work.
The error occurs even if no project is opened, so the problem is caused either by Visual Studio 2015, by Qt 5.14, or by Qt VS Tools extension.
P.S. Sorry if my english wasn't perfect. Waiting for any ideas on fixing this problem.
For any future readers who have this problem, start your maintenance tool or Qt installer, e.g. C:\Qt\MaintenanceTool.exe, "Add or remove components", and then make sure Qt/<version>/MSVC is installed, as shown in the image below:
.
Then you'll be able to select that Qt version instead of MinGW, since the Visual Studio extension only supports the MSVC compiler and not MinGW.
Encountered the exact same problem and the only solution I have found was reverting to an older version of the Qt Visual Studio Tools extension.
Visual Studio has been painfully persistent about updating the version even once I installed an older one, so make sure to disable automatic extension updates (Extensions → Manage Extensions → Extension Settings → Uncheck Automatically search for updates/Automatically update extensions).
Hope it helps.
To solve your problem, you need to remove the QTDIR and QMAKESPEC environment variables that remain in Windows after installing older versions of Qt.
Well, after some more procedures that didn't help, I just did clean-reinstallation for my Windows 10. Fortunately, that helped :)

Using UE4 with Visual Studio 2017

I recently did some cleaning of my drives. I decided to install visual studio 2017 after cleaning the drives up. I have been trying to continue work on my old UE4 project using the engine pulled from GitHub. I tried rebuilding the project with VS2017 which I know is not fully supported yet. I did run into quite a few problems, including the missing corecrt.h files. I reinstalled the Windows SDK to fix this.
The current problem is a new missing file called windows.h, and I believe it is missing due to the build tools looking for the wrong version of the SDK. I was wondering, has anyone else successfully integrated Visual Studio 2017 with their UE4 project after running into similar problems?
-- Edited due to poor grammar.
As I know Version 4.15 supports both Visual Studio 2015 (default) and Visual Studio 2017. If you are building the Engine from source code, you would want to open a command prompt after running Setup.bat and run the command GenerateProjectFiles.bat -2017. This will give you a Visual Studio 2017 solution for the Engine.
To use Visual Studio 2017 for projects, you can set your preference for which version projects use by going to Edit -> Editor Preferences -> General -> Source Code and choosing Visual Studio 2017 in the Source Code Editor setting.
If regenerating the Engine's VS project files doesn't help. Try regenerating your own UE4 project's VS project files.
With Visual Studio and UE4 closed, find the .uproject file, right click and select Generate Visual Studio project files.
Open the solution, make sure your UE4 game (e.g. MyProject) under the Games folder is set as the StartUp project (right click, Set as StartUp project), then try a compile.

How to fix the error "Windows SDK version 8.1" was not found?

I recently updated visual studio 2015 and now, when i try to build any project it always fails and i get the error
Severity Code Description Project File Line Suppression State
Error MSB8036 The Windows SDK version 8.1 was not found. Install the required version of Windows SDK or change the SDK version in the
project property pages or by right-clicking the solution and selecting
"Retarget solution". Proj D:\Program Files (x86)\visual studio
2017\Common7\IDE\VC\VCTargets\Platforms\Win32\PlatformToolsets\v141\Toolset.targets 34
I retargeted the solution as it said, and the problem persisted, even though the retargetting was completed.I decided to install visual studio 2017 because of this, and, lo and behold, it did the exact same thing.I'm also using windows 7.
What is the problem and how can i fix it?
I faced this problem too. Re-ran the Visual Studio 2017 Installer, go to 'Individual Components' and select Windows 8.1 SDK. Go back to to the project > Right click and Re-target to match the SDK required as shown below:
I installed the 8.1 SDK's version:
https://developer.microsoft.com/en-us/windows/downloads/sdk-archive
It used 1GB (a little more) in the installation.
Update October, 9 (2020). There's a https error: the sdksetup link is https://go.microsoft.com/fwlink/p/?LinkId=323507
"Save link as" should help.
Another way (worked for 2015) is open "Install/remove programs" (Apps & features), find Visual Studio, select Modify. In opened window, press Modify, check
Languages -> Visual C++ -> Common tools for Visual C++
Windows and web development -> Tools for universal windows apps -> Tools (1.4.1)
and Windows 10 SDK ([version])
Windows and web development -> Tools for universal windows apps -> Windows 10 SDK ([version])
and install. Then right click on solution -> Re-target and it will compile
I had win10 SDK and I only had to do retarget and then I stopped getting this error. The idea was that the project needs to upgrade its target Windows SDK.
I realize this post is a few years old, but I just wanted to extend this to anyone still struggling through this issue.
The company I work for still uses VS2015 so in turn I still use VS2015. I recently started working on a RPC application using C++ and found the need to download the Win32 Templates. Like many others I was having this "SDK 8.1 was not found" issue. i took the following corrective actions with no luck.
I found the SDK through Micrsoft at the following link
https://developer.microsoft.com/en-us/windows/downloads/sdk-archive/ as referenced
above and downloaded it.
I located my VS2015 install in Apps & Features and ran the repair.
I completely uninstalled my VS2015 and reinstalled it.
I attempted to manually point my console app "Executable" and "Include" directories to the C:\Program Files (x86)\Microsoft SDKs\Windows Kits\8.1 and C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools.
None of the attempts above corrected the issue for me...
I then found this article on social MSDN https://social.msdn.microsoft.com/Forums/office/en-US/5287c51b-46d0-4a79-baad-ddde36af4885/visual-studio-cant-find-windows-81-sdk-when-trying-to-build-vs2015?forum=visualstudiogeneral
Finally what resolved the issue for me was:
Uninstalling and reinstalling VS2015.
Locating my installed "Windows Software Development Kit for Windows 8.1" and running the repair.
Checked my "C:\Program Files (x86)\Microsoft SDKs\Windows Kits\8.1" to verify the "DesignTime" folder was in fact there.
Opened VS created a Win32 Console application and comiled with no errors or issues
I hope this saves anyone else from almost 3 full days of frustration and loss of productivity.
Grep the folder tree's *.vcxproj files. Replace <WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion> with <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion> or whatever SDK version you get when you update one of the projects.
For me in the Project Properties Settings General->Target Platform -> Change Windows 8.1 to Windows 10 solved the issue
Install the required version of Windows SDK or change the SDK version
in the project property pages
or
by right-clicking the solution and selecting "Retarget solution"
If you do visual studio guide, you will resolve the problem.
I encountered this issue while trying to build an npm project. It was failing to install a node-sass package and this was the error it was printing. I solved it by setting my npm proxy correctly so that it could reach the npm repo
PROBLEM: I ONLY get this compile-time "Windows SDK version 8.1 not found" error ( and a few other very-hard-to-resolve-nuisance errors -- cannot list them all ) when I export a project from an old version of MS Visual Studio (VS) to the new MS VS (2017), using the new MS VS export/"One-way Upgrade" feature.
SOLUTION: I have since learned to not use this export/upgrade feature and instead just create the new project from scratch -- using all my old source files, of course. Only my project settings have to be rebuilt, to be clear.
This is a bit of a pain, and a shame the export/upgrade feature won't work properly like it used to, but this is is actually easier and faster in the long run. MUCH better than working through a list of spurious errors that really should not have arisen in the first place.
Hope this helps...

MFC development in vs2017

When I installed vs2017, I did select Windows development with C++ option. After installation, however, I don't see the MFC has been added. Sure enough, I get errors when I compile my application,
fatal error C1083: Cannot open include file: 'afxwin.h': No such file or directory
I cannot find the Change/Modify option with my vs2017 installation in Control Panel. How can I add "Microsoft Foundation Classes for C++" package?
If you look near the top of the VS Installer window, you'll see Workloads, Individual Components and Language Packs.
At least as far as I can see, none of the "Workloads" will include MFC in your installation. To get it, you first have to click on "Individual Components", then scroll quite a ways down to get to the "SDKs, libraries and frameworks" section. In there, you'll find a list of components for ATL and MFC support:
In the VS 2019 installer, the list of possibilities has gotten even longer. There are versions for ARM, ARM64, and x86/x64 both with and without Spectre mitigations, for each of the 141 and 142 build sets:
That's not necessarily the end of the story though: by default, even when you install that, it only installs the version Unicode build of MFC. If you want the narrow-character version, you have to install that separately. I don't think there's any entry in the installer to do this at all--but if you try to build a project that uses narrow-character MFC, you'll get an error message that includes a link to download it.
In Windows 10 with Visual Studio 2017 Community Edition to modify the Visual Studio 2017 installation, I had to go into Settings from the Windows Start menu then in the search box enter "Apps & Features" to bring up the list of installed applications (just typing in "apps" was enough to bring it up in the list).
I then looked for Microsoft Visual Studio 2017 in the list of apps, clicked on that entry which then displayed the Modify button. Clicking on the Modify button will bring up the installer to allow you to modify the various components.
I have seen cases where the installer wants to do an Update of Visual Studio 2017 before allowing you to do the Modify action. Depends on the last time you used it and the last time you did an update.
So instead of a Modify button there may instead be an Update button.
Note: see also How to install (v142) Build tools in Visual studio which describes issues seen with install order when installing both VS 2017 and VS 2019.
The VS 2017 Modify dialog has three tabs, "Workloads", "Individual components", and "Language packs". Click on the "Individual components" then scroll down to the section titled "SDKs, libraries, and frameworks" which is the last section in my install. There should be an entry for "MFC and ATL support (x86 and x64)" with a checkbox near the end.
There is a lot of stuff available from this "Individual components" view of the "Modify installation" dialog.
Just to add a tip for VS 2019:
#Jerry Coffin's answer does a good job of laying out the explosion of MFC/ATL options in VS 2019. Since there are many options and each MFC pack is 1.1+GB, here is how to pick the right one.
Platform: Hopefully you know this :) but it is in project properties.
Version: For an existing project, it is found in the project properties under "Configuration Properties -> General -> Platform Toolset"
Below is a screenshot showing both (Win32=x86 in this case). In this case I needed "C++ MFC for v141 build tools (x86 & x64)":
You should use Visual Studio Installer to make changes.
To create an MFC project, you just need to select Win32 project/Win32 Console Application for your application type, and then click OK. In Application Wizard, click next, in Application Settings, check MFC under Add common header files for:.

MFC Multibyte Add-on for Visual Studio 2015 Express for Desktop

I'm using VS 2015 Express for Desktop which doesn't have MFC Multibyte support by default.
Not long ago there was a separate MFC MBCS DLL Add-on.
But now link to Multibyte MFC Library for Visual Studio 2015 is removed.
That was done because all other VS editions have "Microsoft Foundation Classes for C++" optional install component:
But VS 2015 Express for Desktop lacks it (it has no optional install components, no "Custom" installation at all)
So the questions are:
Maybe someone has a backup link to the download Multibyte MFC Library for Visual Studio 2015?
I've also downloaded VS 2015 Community Edition ISO. In the \packages\VisualC_D14 there are several VC_MFC.* folders (VC_MFC.MBCS among them). But trying to run executables inside that folder leads to an error
Maybe someone knows howto install that components without running whole VS 2015 Community Edition setup?
Thank you in advance.
P.S. Installing VS 2015 Community Edition instead of VS 2015 Express for Desktop is not suitable for my company due to license limitations (we are enterprise organization - over 250 PCs - and use VS for commercial purposes).
Unfortunately changing the character set from multibyte to Unicode in our projects is also not an option for us now.
I have one solution for this. kindly follow the steps to add MFC for C++
step 1: close any Opened Visual Studio.
Step 2: open a Visual Studio and choose File->New -> Project
Step 3: In New Project Pop UP, Select Templates->Visual C++ -> MFC
Step 4: In the Listed Project/files, you will see "Install Microsoft
Foundation classes for C++". Double Click on it.
Step 5: "Install Missing Features" Popup Come with two Button
"Install and Cancel". Saying "Install Microsoft Foundation Classes
for C++. You Simple Click on "Install".
Step 6: Important "Close the opened VS" and you will see Visual
Studio Setup Wizard come with option "Microsoft Foundation Classes"
Within Features Tab. Just Click on "Next" and then a new Window
Appear click on "Update". Your MFC will start updating.
Step 7: Enjoy coding.....
As far as I see my installation the files are always installed if you install the MFC.
I just rechecked it on a different machine. The appropriate MBCS libs are installed by Default, when you choose MFC in the installation of VS-2015.