Visual Studio 2017 C++ linux app, headers not copied to target - c++

I have a VS 2017 C++ linux app which is deployed to the Bash on Windows linux subsytem in Windows 10. I have included header directories using the C++ project properties 'Additional Includes'. However when the project is compiled, the compiler complains that it cannot open header files. As the source files are being compiled on the target machine as opposed to locally, I assume the header files need to be copied there as well but what setting is required for this. Currently they are not being copied, they can be browsed to in the IDE however
Thanks

Tested on Visual Studio Community 2017 15.9.7 and Visual Studio Enterprise
2019 Preview 4.
Visual Studio needs to download all remote headers in your localmachine for correct behavior of intellisense.
New method 'rsync_ssh' doesn't download all headers. You can use old method .zip via sftp_ssh.
0. Add remote connection.
Tools->Options->Cross Platform->Connection Manager
1. Select your connection
Update from Tools->Options->Cross Platform->Connection Manager->Remote Headers Intellisense Manager.
Next click on Explore button.
2. C:\Users[YourUser]\AppData\Local\Microsoft\Linux\HeaderCache\1.0[IdNumber]
Rename the HeaderCache settings.xml.unused file to settings.xml
3. In the settings.xml file Change the syncMethod to sftp_ssh.
4. Update headers cache from Tools->Options->Cross Platform->Connection Manager->Remote Headers Intellisense Manager.
5. Enjoy.
Before
After

Visual C++ for Linux Development (VCLinux) doesn't copy headers to the remote (Linux) system that are not in the Visual Studio project.
VCLinux installs copies of most of the common Linux system headers (/usr/include etc.) on the Windows host so that IntelliSense can see them but the system headers for the Linux system must be present on the remote for your application to compile (with g++). System headers are on the include search path for g++ by default. And the VCLinux copies are on the Visual Studio IntelliSense include path by default. If you have had to specify Additional Includes it suggests that the headers you're interested in belong to some optional component which you'll probably have to explicitly install on the Linux remote.
It's worth remembering that Windows Subsystem for Linux (WSL) is still limited, i.e. it doesn't (yet) have everything you would find in a conventional Linux distro like Debian. And while grabbing the missing headers from somewhere could allow your application to compile it might to fail to link or run.
This might also be of interest: Linux header file not recognized in Visual Studio 2017 Linux Project

Related

Visual Studio: copy installation folder and setup it up to be auto-detected by Qt Creator

I wiped out an old Windows 10 and replaced it with a new Windows 10 by ISO image.
Before wiping out, I copied the folder of Microsoft Visual Studio 2017 Community Edition on old Windows to an external hard disk:
xcopy /E "C:\Program Files (x86)\Microsoft Visual Studio" D:\
Now after reinstalling Windows 10, I copied the VS 2017 folder from external the hard disk to the C:\Program Files (x86)\ folder of new operating system.
I did so to avoid having to download VS 2017 again on new OS.
The problem is other software, like Qt Creator, cannot auto-detect the VS C/C++ compilers. I guess that's because the VS 2017 isn't added to path.
The questions are:
What path should I add to system path in order to VS 2017 to be auto-detected by other software like Qt Creator?
Is there any script which I can run to automatically integrate the VS 2017 to the rest of the operating system.
To answer the questions in your issue:
Copying the content of C:\Program Files (x86)\Microsoft Visual Studio folder is not a recommended way to install VS.
(The complete installation will not only set the Environment variables but also set the related registry keys and values. A simple copy may break this process)
So we always suggest that users install the VS by vs-installer or offline installation package. (Same like what Zlatomir suggests.)
To your actual requirements:
It seems you're just trying to use VC++ compiler in QT Creator instead of developing QT projects in Visual Studio. So build tools for VS package is enough for you.
See this related issue, if we download Build Tools for VS package with corresponding C++ workload, then we can get the compiler the QT needs. There's no need to install the VS IDE for this situation.
And if we need C++ compiler from VS2017, download the Build Tools for VS2017, if we need C++ compiler from VS2015, download the Build Tools for VS2015 Update3. Link of old version about VS Tools see here.
Update:
From the the link older downloads we can see:
Choose the download button according to which version we need. We can find both VS2017 build tools package and VS2015's there.
Usually programs on Windows don't work after you just copy the installation folder.
So right now there is little you can do to fix it, even if you partially fix, you have no way to know if something else will be broken in the future.
So the recommended solution is to download the installer again and create an offline installer for the next time this happens, you can do that by running the online installer with the following parameters: vs_community.exe --layout c:\vslayout --lang en-US (replace vs_community.exe with the actual name of the online installer file, or rename it), for more options, that might require a smaller download (example if you only need native and don't need .net) check the documentation here for the full set of options you have.

Visual Studio 2017 cross-platform Linux project with boost

I'd like to ask how to include boost hpp files in cross platform Linux project. I am developing on Windows and compiling remotely on Linux with VS 2017.
For IntelliSense the C++ header files from Linux are automatically copied to Windows machine.
Is it the case with boost hpp files also?
How is it in a case when boost is just extracted from a package on Linux and not installed by apt-get... command?
Do I need to install boost on Windows also?
How to refer to hpp files so that both VS IDE and g++ would find the files?
Thanks.
I have to figure out how to make it work, so I post it here if someone else needs a help:
To make IntelliSense work, the boost has to be on Windows. The VS can not be instructed to download additional include files from Linux. What it downloads from Linux is not user configurable in VS 2017, so we have to install or download boost files on Windows manually.
Add the path to VS in Configuration Properties->C/C++->General->Additional Include Directories. For example $(ProjectDir)../../boost_1_68_0/;
Add path to boost which is on Linux machine. For example: /usr/local/boost_1_68_0/;
Now you should be able to compile VS solution and IntelliSense should work.
If someone knows how to avoid installation of boost on Windows and use only boost installation on Linux, please let me know. I don't understand why VS does not allow to manually specify additional includes for a download.

How to write GTK applications in Visual Studio c++ for Linux platform?

I made c++ project for Linux platform in Visual Studio and connected to linux virtual machine with g++, gdb, gdbserver and libgtk-3-dev. But I can't compile program with gtk.h lib. What do I need to do for Visual Studio to detect gtk?
Visual C++ for Linux builds your application on the target Linux system. Therefore the GTK+ headers and libraries need only be present on the Linux target. However, if you want IntelliSense to work (and who wouldn't) the GTK+ headers need to be visible to Visual Studio on the Windows host. The easiest way to do this is to copy the headers onto the Windows host (put them in their own folder). The include path in Visual Studio's project settings must specify the Linux path for the GTK+ headers for g++ on the Linux target and the Windows path on the Windows host.
This question might give you some more information.
And, as you are using c++, you might like gtkmm which provides c++ bindings for GTK+.

how to get VS2013 c++ compiler to use with Qt without installing VS2013 [duplicate]

As per the title. I don't want to download the entire Visual C++ installer, only "cl.exe" and the other programs required for compiling and linking C++ programs on Windows.
As said, there is no way to do that. You need to download the entire 4-6GB+ bundle. MS deployment is a botch.
There is no need, however, to actually install everything. If you're up to some manual installation, you can extract individual components from the bundle and put them all in a more organized directory tree.
For example, I've found the following set to be the bare minimum needed for using the current MSVC2013 compilers in a x86 environment:
vc_compilerCore86.msi: MSVC toolchain;
vc_compilerCore86res.msi: MSVC toolchain MUI resources;
vc_librarycore86.msi: MSVC library stuff;
vc_LibraryDesktopX86.msi: More MSVC library stuff;
Windows Software Development Kit for Windows Store Apps-x86_en-us.msi: Windows SDK files and related tools (rc.exe, mt.exe, etc.);
Windows Software Development Kit-x86_en-us.msi: More Windows SDK files (specifically, WinSock2.h, WS2_32.lib, maybe others).
Remember that you can extract the contents of a MSI file by running msiexec /a <msifile> TARGETDIR="<path>" (jot a /quiet parameter if you're batching). Of course, you can also put more into your package by investigating the MSI files inside the bundle. In particular, the above set is missing the latest MSBuild tools, since I don't care for them. Stuff is often scattered around between multiple MSIs cluelessly, so good luck.
I've got a 50MB (!!!) 7z-file containing this set for local deployment, though I cannot share this publicly due to Microsoft licensing restrictions.
UPDATE:
This is the list of MSI files for MSVC2015 tools, headers and libraries:
packages\VisualC_D14\VC_Tools.Core\VC_Tools.Core.msi
packages\VisualC_D14\VC_Tools.Core.Res\VC_Tools.Core.Res.msi
packages\VisualC_D14\VC_Tools.X86.Base\VC_Tools.X86.Base.msi
packages\VisualC_D14\VC_Tools.X86.Base.Res\VC_Tools.X86.Base.Res.msi
packages\VisualC_D14\VC_Tools.X86.Nat\VC_Tools.X86.Nat.msi
packages\VisualC_D14\VC_Tools.X86.Nat.Res\VC_Tools.X86.Nat.Res.msi
packages\VisualC_D14\VC_Tools.X86.X64\VC_Tools.X86.X64.msi
packages\VisualC_D14\VC_Tools.X86.X64.Res\VC_Tools.X86.X64.Res.msi
packages\VisualC_D14\VC_PremTools.X86.Base\VC_PremTools.X86.Base.msi
packages\VisualC_D14\VC_PremTools.X86.Base.Res\VC_PremTools.X86.Base.Res.msi
packages\VisualC_D14\VC_PremTools.X86.Nat\VC_PremTools.X86.Nat.msi
packages\VisualC_D14\VC_PremTools.X86.Nat.Res\VC_PremTools.X86.Nat.Res.msi
packages\VisualC_D14\VC_PremTools.X86.X64\VC_PremTools.X86.X64.msi
packages\VisualC_D14\VC_PremTools.X86.X64.Res\VC_PremTools.X86.X64.Res.msi
packages\VisualC_D14\VC_CRT.Headers\VC_CRT.Headers.msi
packages\VisualC_D14\VC_CRT.X86.Desktop\VC_CRT.X86.Desktop.msi
packages\VisualC_D14\VC_CRT.X86.Store\VC_CRT.X86.Store.msi
packages\VisualC_D14\VC_CRT.X64.Desktop\VC_CRT.X64.Desktop.msi
packages\VisualC_D14\VC_CRT.X64.Store\VC_CRT.X64.Store.msi
packages\VisualC_D14\VC_CRT.Redist.Res\VC_CRT.Redist.Res.msi
packages\VisualC_D14\VC_CRT.Redist.X86\VC_CRT.Redist.X86.msi
packages\VisualC_D14\VC_CRT.Redist.X64\VC_CRT.Redist.X64.msi
packages\VisualC_D14\VC_ATL.Headers\VC_ATL.Headers.msi
packages\VisualC_D14\VC_ATL.X86\VC_ATL.X86.msi
packages\VisualC_D14\VC_ATL.X64\VC_ATL.X64.msi
packages\VisualC_D14\VC_MFC.Headers\VC_MFC.Headers.msi
packages\VisualC_D14\VC_MFC.X86\VC_MFC.X86.msi
packages\VisualC_D14\VC_MFC.X64\VC_MFC.X64.msi
packages\VisualC_D14\VC_PGO.Headers\VC_PGO.Headers.msi
packages\VisualC_D14\VC_PGO.X86\VC_PGO.X86.msi
packages\VisualC_D14\VC_PGO.X64\VC_PGO.X64.msi
packages\Win10_UniversalCRTSDK\Universal CRT Headers Libraries and Sources-x86_en-us.msi
And this is the list of MSI files for WinSDK10 tools, headers and libraries (downloaded separately):
Installers\Windows SDK Desktop Headers Libs Metadata-x86_en-us.msi
Installers\Windows SDK Desktop Tools-x86_en-us.msi
Installers\Windows SDK for Windows Store Apps Headers Libs-x86_en-us.msi
Installers\Windows SDK for Windows Store Apps Tools-x86_en-us.msi
All of this include stuff for both x86 and x64 (I haven't considered ARM or IA64). Both bundles compressed with LZMA will yield a 185MB file.
Locked. There are disputes about this answer’s content being resolved at this time. It is not currently accepting new interactions.
In 2014 you could not download the Visual C++ compiler alone from Microsoft.
It used to be that you could. Then it used to be that you could get it in the Platform SDK. Then you could only get it by installing Visual Studio.
Happily, at that time, the compiler that was bundled with Visual Studio Express for Desktop (the free version of Visual Studio at the time) was, and is, the very same that you get with Professional or Universal editions.
In November 2015 Microsoft again started providing the compiler tools in a free-standing package called the Visual C++ Build Tools.
Microsoft writes:
” the C++ Build Tools installer will not run on a machine with Visual Studio 2015 already installed on it. The reverse (i.e. upgrade to Visual Studio) is supported.
The long term situation is, as always, unclear. And, disclaimer: I have not used the build tools myself – I would have to uninstall Visual Studio first.
I ended up using Chocolatey, which has a package for Visual C++ Build Tools.
This command:
choco install visualcpp-build-tools
will install the latest 2017 version, but you can select one of the older versions, which include the 2015 release.
After the installation Visual Studio 2017 folder is added to the Programs menu. It includes shortcuts to various developer command prompts with cl.exe and other tools in the path.
As of 2019 Microsoft offers Visual Studio Build Tools which only includes the compiler, build tools and SDK. It's hidden in the all downloads list.
Update: The Visual C++ 2015 Build Tools are located here: http://landinghub.visualstudio.com/visual-cpp-build-tools
The Visual C++ 2017 Build Tools are now part of the regular VS 2017 installer. Just select the workloads you need. Information is on the same page.
This link is preferred to the blog links below as it's the official landing page and will be kept up-to-date.
I'm on the C++ team. If you have any questions about using the VC++ Build Tools or about MSVC in general, feel free to email me. My email is my StackOverflow user name #microsoft.com.
Once I tried to do same this as you. But MS doesn't provide isolated compiler. So if you need MS C++ compiler you must need to install the VS. But if you like to adventure. there is a tricky way to do that. Try it here.
Chrees!
You can use MSVC compiler without Visual Studio and the latest version is available here:
http://www.microsoft.com/en-us/download/details.aspx?id=41151
Also here's a website which details the command line options for the compiler:
http://msdn.microsoft.com/en-us/library/9s7c9wdw.aspx
As of the time of writing (June 23, 2021), the following info is taken from Configure VS Code for Microsoft C++.
Here is the important quote:
You can also install just the C++ Build Tools, without a full Visual
Studio IDE installation. From the Visual Studio Downloads page, scroll
down until you see Tools for Visual Studio under the All downloads
section and select the download for Build Tools for Visual Studio.
This will launch the Visual Studio Installer, which will bring up a
dialog showing the available Visual Studio Build Tools workloads.
Check the C++ build tools workload and select Install.
Note: You can use the C++ toolset from Visual Studio Build Tools along
with Visual Studio Code to compile, build, and verify any C++ codebase
as long as you also have a valid Visual Studio license (either
Community, Pro, or Enterprise) that you are actively using to develop
that C++ codebase.
As what stated in visual c++ 2015 tools for windows desktop
Mount your VS2015.iso
You can find all packages at your mounted location E:\packages | G:\packages
Navigate to Control Panel.
Right-Click at your VS2015 and choose change-modify
Check the Visual C++ boxes as stated in the link.
Click on Modify.
If installer fail to update, copy the mounted directory location and paste on it.
Click Retry button.
On March 21, 2022, the best I could figure out was to find the "Visual Studio Community" free download (required logging in with Microsoft account). There was no longer any "just give me the damn Build Tools" concept, but there is the promise that you just download an installer and then pick. So I downloaded the installer and ran it.
Of course, none of the top-level options are suitable for "just give me the damn Build Tools", so I pick the "Individual Components" option. This supplies an incredibly large list of things I don't want, but buried within it I find "MSVC v143 - VS 2022 C++ x64/x86 build tools (Latest)" which looks hopeful. I check that box and I'm informed they will give me also "Visual Studio code editor".
I'm sternly warned that I'm installing "without workloads", which seems to be some additional crap that the "Visual Studio core editor" I'm never going to use wants. I decline the additional bloatware. Some gigabytes later, it says I'm "Done installing" but warns "We recommend rebooting soon to clean up any remaining files."
After decades of (re-)writing scripts to locate the Microsoft compiler, I bow to Microsoft's superior ability to keep breaking any easy method of automating this process. Whenever I install the Microsoft compiler on a system, I manually set a system-wide environment variable that points to the Microsoft batch file for setting shell environment variables for the tools. Today's machine is a no-license (hey, Microsoft sucks the same way, just not as much!) Windows 10, and that is <Winkey>-x | System | Advanced System settings | Environment Variables
I create a variable called RLBVCVARS and set it to (in this particular case) c:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat My portable Windows dev environment keeps an alias that points to that so, I can mostly pretend Microsoft doesn't constantly introduce breaking changes to their installation schemes. I think you have to reboot for a "system" environment variable to take effect, but hey, Microsoft wants you to reboot after installing anything anyway, so no biggy.
First compile says can't find "io.h". Back to the installer. Let's try adding "Windows 10 SDK" (3 versions to choose from!). A GB or so later, I have an io.h and can build my current project. Onward and upward.

Is the visual c++ express cmd prompt missing features?

I tried compiling the POCO library on my Windows 7 computer. Though I use eclipse cdt, it said that It could only be compiled with Visual C++:
Microsoft Visual Studio 7.1 (2003), 8.0 (2005), 9.0 (2008) or 10.0
(2010) is required to build the POCO C++ Libraries on Windows
platforms. Solution and project files for all versions are included.
For Visual Studio 2008 and 2010, 64-bit (x64) builds are supported as
well. You can either build from within Visual Studio (Build->Batch
Build->Select All;Rebuild) or from the command line. To build from the
command line, start the Visual Studio .NET 2003/2005/2008/2010 Command
Prompt and go (cd) to the directory where you have extracted the POCO
C++ Libraries sources. Then, simply start the buildwin.cmd script and
pass as argument the version of visual studio (71, 80, 90 or 100). You
can customize what is being built by buildwin.cmd by passing
appropriate command line arguments to it. Call buildwin.cmd without
arguments to see what is available. To disable certain components
(e.g., NetSSL_OpenSSL or Data/MySQL) from the build, edit the text
file named components in the distribution root directory and remove
the respective lines. Certain libraries, like NetSSL_OpenSSL, Crypto
or Data/MySQL have dependencies to other libraries. Since the build
script does not know where to find the necessary header files and
import libraries, you have to either add the header file paths to the
INCLUDE environment variable and the library path to the LIB
environment variable, or you'll have to edit the buildwin.cmd script,
where these environment variables can be set as well. In order to run
the test suite and the samples, the top-most bin directory containing
the resulting shared libraries must be in the PATH environment
variable.
I downloaded visual c++ express, but when I run the "buildwin.cmd" I get these errors:
devenv is not recognized as an internal or external command.
I also can't find any "build" menue inside the program. Is the full Visual C++ required to build the library? If so, is there any cheaper option?