tech74
tech74

Reputation: 1659

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

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

Upvotes: 2

Views: 2623

Answers (2)

Joma
Joma

Reputation: 3859

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.

image

2. C:\Users[YourUser]\AppData\Local\Microsoft\Linux\HeaderCache\1.0[IdNumber] Rename the HeaderCache settings.xml.unused file to settings.xml

image

3. In the settings.xml file Change the syncMethod to sftp_ssh.

image

4. Update headers cache from Tools->Options->Cross Platform->Connection Manager->Remote Headers Intellisense Manager. 5. Enjoy.

Before

image

image

After

image

image

Upvotes: 1

stanthomas
stanthomas

Reputation: 1181

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

Upvotes: 0

Related Questions