Hitting breakpoints using LLVM-vs2014 in Visual Studio - c++

I am using Visual Studio 2017 (version 15.3.5) and the official LLVM 5.0.0 pre-built binary Clang for Windows (have tried 32-bit and 64-bit)
When I create a simple hello world project, compile using the LLVM-vs2014 platform toolset, and launch the Local Windows Debugger, I cannot hit a breakpoint. When I change the platform toolset to Visual Studio 2017 (v141), I can hit breakpoints.
Are there some extra steps required to get the Local Windows Debugger to work using the LLVM-vs2014 platform toolset?

Related

Why do I get "Illegal Instruction" error when Building on windows10 and running on Windows7

I have a c++ program built using VS2017 on windows7.
When I run it on Windows7 or windows10 there is no problem.
If I Build the same program on Windows10 (still using VS2017) the program runs OK on Windows10 but when I try to run it on Windows7 I get an "0xC000001D: Illegal Instruction." error.
Is it even possible to run programs built in Windows10 on Windows7 ? and if so what can I do?
Thanks
The default SDKs will be different on your two VS2017 installations. Right-click the project, select "properties", then the "General" page. See Windows SDK Version.
You can install different SDK versions (and different Platform Toolsets) using the Visual Studio installer ("Modify").
You would probably need to install the v140 toolset.
Also see the response here:
https://social.msdn.microsoft.com/Forums/vstudio/en-US/e19634d8-f635-4ed0-b8d7-45b64ccbd6fa/windows-sdk-7-in-visual-studio-2017?forum=visualstudiogeneral
...which states:
You can create a project with the default project template. After that, right click the project name under Solution Explorer and go to Configuration Properties-General, modify the 'Platform Toolset' to Windows7.1SDK, since you already installed the Windows SDK 7. Please have a look at the following note:
##To change the target platform toolset, you must have the associated version of Visual Studio or the Windows Platform SDK installed. For example, to target the Itanium platform with the Windows7.1SDK platform toolset, you must have Microsoft Windows SDK for Windows 7 and .NET Framework 4 SP1 installed
If the above not works, you can also modify the platform toolset to Visual Studio 2010 (v100), which has the same compiler like Windows SDK 7, if you have the VS 2010 and VS 2017 on the same computer

How to configure a usable Kit for Qt after reinstalling Visual Studio 2017

I reinstalled Visual Studio 2017 and just couldn't configure a working Kit for Qt.
Summary:
At the very beginning, I had both Qt5.9.8 MSVC2017_64bit and Visual Studio 2017 installed on my computer. They just worked fine. Then I updated Visual Studio to 2019 and uninstalled VS2017. Then my Qt Creator broke down. When I try to open a Qt project created before, it just prompts me that "No valid kits found".
What I tried :
I tried to reinstall something 'needed', attempting to restore something for Qt to work. So I opened Visual Studio Installer, checked to install Single Component "VC++ 2017 version 15.9 v14.16 latest v141 tools" of Visual Studio Enterprise 2017. Then I opened Qt Creator 4.8.2, Menu->Tools->Kits, manually added a clang-cl C and C++ compiler and set the compiler path each to "C:\Program Files (x86)\Microsoft Visual Studio\2017\VC\Tools\MSVC\14.16.27023\bin\Hostx64\x64\cl.exe".
I also tried some combinations between Hostx64, Hostx86 and x64, x86 when selecting the path. But none of then succeeded.
Besides, I have heard and taken a shot on Qt VS Tools.
Related environments:
Microsoft Visual Studio 2019 Enterprise
Microsoft Visual Studio 2008 Professional (whose compiler was
auto-detected in Qt but not usable)
Qt 5.9.8 MSVC2017_64bit
Question :
Would anyone tell me what I can do to solve this troubling problem?
cl.exe is not clang, so you will not make it work by forcing cl.exe into a clng configuration in Qt Creator.
As of today, there is no way to set an MSVC compiler toolchain manually in Qt Creator. The only way is to have it auto-detected. If your MSVC toolchain is not detected, the first thing to do is to update Qt Creator (current version is 4.9.2) becaue each released of Qt Creator has improved detection methods for the new MSVC releases.
I know that Microsoft has standardized the way to detect installed toolchains with 2019. So if you use MSVC 2019 + Qt Creator 4.9+, yous should not have any problem.
Note that in the past Qt Creator had issues with:
MSVC Build Tools (MSVC toolchain without Visual Studio GUI)
Installing old toolchains with new installer e.g. installing MSVC 2015 as part of Vistual Studio 2017 installation.
Also, by default Visual Studio does not install the command line debuger by default. You need to go to "Add and remove programs" and modify the Windows SDK installation by enabling the debug tools.

How can I set up Visual Studio 2017 to develop drivers?

According to this forum, https://answers.microsoft.com/en-us/windows/forum/windows_10-hardware-winpc/windows-wdk-on-visual-studio-2017-community/fdbd2b44-e57a-4849-903d-04001205a764
Windows Driver Kit is not currently supported by visual studio 2017.
I tried installing the Windows Driver Kit, but the test driver projects, such as this one, fail to build
https://github.com/Microsoft/Windows-driver-samples/tree/master/serial/VirtualSerial
I get this error when building:
Error MSB8020 The build tools for WindowsUserModeDriver10.0 (Platform Toolset = 'WindowsUserModeDriver10.0') cannot be found. To build using the WindowsUserModeDriver10.0 build tools, please install WindowsUserModeDriver10.0 build tools. Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Retarget solution".
I already tried retargeting the Solution to the two options I have: 10.0.17134.0 and 8.1, but the same error keeps coming up.
What do I need to do to build this sample driver? Do I need to install VS2015? VS2017 community edition? Why isn't this WDK supported by the Visual Studio 2017 professional version?
Thanks,
Visual Studio 2017 definitely supports kernel-mode device driver development; there's no doubt about that because I've been using VS17 for it for many, many months.
Use the latest version of Windows Driver Kit (WDK) which can be downloaded and installed from MSDN: https://learn.microsoft.com/en-us/windows-hardware/drivers/download-the-wdk
Furthermore, you can always use the Enterprise WDK and then you can simply build using that if you wanted to from command-line. (Also can be found on page linked-to above)
Download the correct WDK installer for your edition of Visual Studio 2017:
WDK for Windows 10, version 1809 for Visual Studio Community 2017
WDK for Windows 10, version 1803 for Visual Studio Professional 2017
WDK for Windows 10, version 1709 for Visual Studio Enterprise 2017
Visit https://learn.microsoft.com/en-us/windows-hardware/drivers/other-wdk-downloads for more information.
Not exactly a solution, but Windows 8.1 WDK works with Visual Studio 2017 Enterprise,
Download it from here, just need to retarget the project to 8.1
https://www.microsoft.com/en-us/download/confirmation.aspx?id=42273
In addition, I needed to get VS2015 C++ Build Tool to fix a missing Microsoft.cpp.props error
http://download.microsoft.com/download/5/F/7/5F7ACAEB-8363-451F-9425-68A90F98B238/visualcppbuildtools_full.exe
Developing drivers to windows is quite interesting one will be exposed to advanced Operating System Concepts.The set up for the environment will be IDE
IDE - Visual Studio (https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=Community&rel=16)
Compilers (WDK)
Debugger (WDK)
WDK contains both(https://go.microsoft.com/fwlink/?linkid=2085767). Latest Visual Studio(VS2019) will come along with the latest WDK(10, 1903 as of now).
Sometimes plugins might not work properly i.e integration issues between Visual Studio and WDk.
By going to the location "C:\Program Files (x86)\Windows Kits\10\Vsix\VS2019" and run VSIX installer.
Now in a new project, driver related templates are available.

How to target Windows XP in Microsoft Visual Studio C++ [duplicate]

This question already has answers here:
MSVCP140.dll missing
(4 answers)
Closed 6 years ago.
I'm using Microsoft Visual Studio 2015 on Windows 8.1. I want to compile a program targeting Windows XP. I've looked it up on Google and other similar questions, but none helped. In the solution settings, target platform toolset is set to the Windows XP one, but there is no option for Windows XP in the target platform version.
I did read https://msdn.microsoft.com/en-us/library/windows/desktop/aa383745(v=vs.85).aspx (Using the Windows Headers) and added these lines to my program:
#define WINVER _WIN32_WINNT_WINXP
#define _WIN32_WINNT _WIN32_WINNT_WINXP
#define NTDDI_VERSION NTDDI_WINXP
But it still doesn't work. It says that it can't find "MSVCP140.dll". After I got this dll, it begins to complain about can't find "VC140.dll". After that is "ucrtbased.dll", and then finally "api-ms-win-core-string-11-1-0.dll", which I don't even have it in my Windows 8.1 computer. The program can run on Windows 8.1, but not Windows XP.
What can I do to make the program run on Windows XP?
In order to build a Windows XP compatible EXE with VS 2015 (or VS 2012 / VS 2013) you have to use the v140_xp Platform Toolset rather than the default v140 Platform Toolset.
UPDATE: Note that VS 2017 includes support for Windows XP via v141_xp. For VS 2019, this feature is no longer being updated but you can still install the v141_xp toolset to use with the VS 2019 IDE.
See your Project Properties, the General page:
This is because the default Platform Toolset uses the Windows 8.1 SDK (or you can opt into the Windows 10 SDK), and this only supports building applications for Windows Vista or later. When you select the v140_xp Platform Toolset, you are using a version of the Windows 7.1 SDK which was the last version to support targeting Windows XP or Windows Server 2003.
Note that Visual Studio can target Windows XP Service Pack 3 or Windows Server 2003 Service Pack 2. The C/C++ Runtime is not compatible with older versions of Windows.
If you are using DirectX in your app, this has some profound implications because a lot changed between the Windows 7.1 SDK and the Windows 8 SDK. See this post for details.
With VS 2015, you will also need to select the Windows XP support in the Custom Install options or via Programs & Features / Microsoft Visual Studio 2015 / Change... / Modify:
It sounds like the program runs fine on your development machine (Windows 8.1 + MSVS 2015), but doesn't run on an XP machine.
SOLUTION: you must include the MSVC runtime along with your .exe.
Look here: Deploying Native Desktop Applications (Visual C++)
and here: Visual C++ Redistributable for Visual Studio 2015.
Update from Chuck Walbourn -
Note that in the particular case of VS 2015 Update 3 and VS 2017, you
can use the VS 2017 or 2019 REDIST and it will work fine. See:
VC Runtime in MSVC 2017 is binary compatible with
2015
and
Microsoft Docs: C++ binary compatibility between Visual Studio
2015, 2017, and
2019.
And to repeat - your "setup" should include a compatible MSVC runtime (aka "VCRedist").

Visual Studio 2015: building with the Windows XP toolset selected still results in "not a valid win32 application" error on XP

Visual Studio 2015 supports building C++ programs for Windows XP. According to the article Configuring C++11 Programs for Windows XP, enabling this support is simply a matter of selecting the appropriate platform toolset in the project properties.
This does not work in my case. A simple "hello world" program written in C++ and compiled in Visual Studio Community 2015 (version 14.0.24720.00 Update 1) with the platform toolset set to Visual Studio 2015 - Windows XP (v140_xp) and the platform set to x86/Win32 generates the generic "[name of executable] is not a valid Win32 application" error when run on a Windows XP computer.
Any suggestions would be appreciated. I've found a number of questions about similar issues (like these three), but nothing helpful yet.