Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include paths not being passed from VSLinux to remote build #170

Closed
braindeaddeveloper opened this issue Aug 11, 2017 · 40 comments
Closed
Assignees

Comments

@braindeaddeveloper
Copy link

I am getting repeated failures to find include files in various VSLinux projects.

An example of this :

From project / properties / c/c++ / command line

"/path to gcc/gcc" -W"switch" -W"no-deprecated-declarations" -W"empty-body" -W"conversion" -W"return-type" -W"parentheses" -W"no-pointer-sign" -W"no-format" -W"uninitialized" -W"unreachable-code" -W"unused-function" -W"unused-value" -W"unused-variable" -std=c++11 -Wall -fno-strict-aliasing -I "/path to gcc/gcc/include/c++/4.8.3" -I "/path to curl/curl/include/" -I "/path to boos/boost/1_57_0/include" -g2 -gdwarf-2 "/path to gcc/bin/g++" -O0 "3600000" -fthreadsafe-statics -W"switch" -W"no-deprecated-declarations" -W"empty-body" -W"conversion" -W"return-type" -W"parentheses" -W"no-format" -W"uninitialized" -W"unreachable-code" -W"unused-function" -W"unused-value" -W"unused-variable" -Werror -frtti -fno-omit-frame-pointer -std=c11 -fexceptions -o "\path to project\teatest001\obj\x64\Debugx64%(filename).o"

But when build is selected I can see from build output window

...
Invoking g++
/path to gcc/bin/g++ -c -x c++ /path to project/teatest001/main.cpp -I "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\Linux\include\usr\local\include" -g2 -gdwarf-2 -o "/path to project/teatest001/obj/x64/Debug/main.o" -Wall -Werror -Wswitch -W"no-deprecated-declarations" -W"empty-body" -Wconversion -W"return-type" -Wparentheses -W"no-format" -Wuninitialized -W"unreachable-code" -W"unused-function" -W"unused-value" -W"unused-variable" -O0 -fno-strict-aliasing -fno-omit-frame-pointer -fthreadsafe-statics -fexceptions -frtti -std=c++11 main.cpp

then I get include file not found errors as you can see includes from the command line window arent being passed to gcc

As this is a remote build on a Linux machine : -I "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\Linux\include\usr\local\include" is pointless but as you can see that is the only include path passed to the remote build.

unfortunately I cant send you more than this ... its a financial institution and a corporate offence to disclose anything more than this

Repro is simple create a VSLinux project against a remote Linux server over ssh add a remote include path to the settings run build then check the outputs command line. Add a source file which has a #include "remoteheader.h" from that include path. Run build and see error.

VS2017 is latest 15.2 version build 26430.16. Remote server Redhat 6.5 GCC version 4.8.3

thanks

@itodirel
Copy link
Member

itodirel commented Aug 21, 2017

@braindeaddeveloper

Regarding the Command Line observation, I want to note that what you see in the Property Pages in the Command Line section, it's an approximation of the actually command line, the reason for that being extra code that we run only during the build and the Property Pages not having access to. For the most part, the discrepancy will only be duplicates and de-duplication.

Regarding additional include directories. The way you can add the directory is using Property Pages - Configuration Properties - C/C++ - General - Additional Include Directories. This is a semi colon separated list, of both local and remote paths. The local paths are only used for IntelliSense, the remote paths are only used for build.

So if you wanted to add a directory say /usr/src/linux-headers-4.8.0-41/usr, the you can just append that to Additional Include Directories, and reference it with #include <> syntax, note that in C++, quotes in #include only resolves files relative to the directory in which the source file the #include is made from, while #include <foo.h> for example, is resolving the header using the Additional Include Directories.

Please let me know if this doesn't work for you or you have more questions.

@braindeaddeveloper
Copy link
Author

Wow ... Ion ... I have been using VS since the early 90's from 1.52 and on NT 3.51 ... the above is like what you suggest to an intern or graduate. If you are saying what appears in the properties -> Configuration -> C++ -> Command Line has no direct relationship to the Command Line actually used (ignoring uniqueness and ordering) then I am worried .... to be precise ... my
-I some path
entries in the above property page do NOT appear in the executed command line and so fail to compile ... I cut and pasted a full example above ... you are ignoring the -I entries there when you say I should be using the Additional Include Directories ... they are there ! look ! above ! in the Command Line page ... but NOT in the executed command line.
If I cut and paste the executed command line into a text editor and add the -I entries ... the compilation is successful.
Not really sure how much more explicit I can be ...

many thanks

@itodirel
Copy link
Member

@braindeaddeveloper, apologies, I'm just trying to cover all the bases. Can you verify one more thing, when you modify the values in Property Pages, is the Active Configuration and Platform selected? In the Property Pages it should say "Active" at the top. Sometimes the configuration or platform can switch from the Active one, so if you add any settings it will effectively not be applied to build if it is not set in the active one.

@braindeaddeveloper
Copy link
Author

Hi Ion
Yes ... the active configuration has the include paths set in property pages but the command line executed doesn't.
BTW As I was aware the Active indication is only a reference to the underlying configuration. So Active(XYZ) points to XYZ. So its XYZ that is the configuration and you can modify those without them being active as in All Configurations or Multiple Configurations.

I have to say this is a killer. thanks

@itodirel
Copy link
Member

itodirel commented Aug 26, 2017

Is -I "/path to curl/curl/include/" specifically, what you're adding to the Configuration Properties - C/C++ - Command Line? I'm not able to reproduce it on 15.2, on the exact same build that you're using (26430.16). Can you try reproducing outside your project, with a simple (new) Console Application project, and see if it's specific with the project that you're using or there is something else going on? So we can further diagnose it and narrow it down. If you're able to reproduce with a Console Application project, then would it be possible to give us the build logs in diagnostic verbosity?

Additionally, I attached a project that I used in one of my attempts to reproduce the problem, would it be possible to open it and try to build it and see if you can see the -I included or not included? To further narrow it down.

ConsoleApplication1.zip

@itodirel
Copy link
Member

itodirel commented Sep 5, 2017

Tentatively closing due to inactivity. If this still reproduces for you, please reactivate and provide us with the repro steps.

@itodirel itodirel closed this as completed Sep 5, 2017
@braindeaddeveloper
Copy link
Author

Hi Ion
I cannot use VSLinux anymore due to this ... none of my projects (and I have upgraded to 15.3) pass ANY include file paths to the remote build apart from the pointless path to the windows folders : -I "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\Linux\include\usr\local\include"

I cannot send any more than I have without risking being expelled from the company as it is a corporate offence to send code of any sort out of the company and there are detectors running ... it is an investment bank.

-I "//curl/include/"

is certainly not what I am passing ... I have just remove the with a place holder

@braindeaddeveloper
Copy link
Author

I don't think it right you closed this ....

@braindeaddeveloper
Copy link
Author

braindeaddeveloper commented Sep 6, 2017 via email

@braindeaddeveloper
Copy link
Author

braindeaddeveloper commented Sep 6, 2017

Hi Ion

I get the following when I try and open your ConsoleApplication project in 15.3:

=====================
06/09/2017 11:21:18
LimitedFunctionality
System.AggregateException: One or more errors occurred. ---> System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.Build.Linux.Shared.RemoteTargetUtils.ProcessorArchToPlatform(String remoteArchitecture)
at Microsoft.Build.Linux.Shared.RemoteTargetUtils.ConnectionToDisplayNameShort(StoredConnectionInfo storedConnectionInfo)
at Microsoft.VisualStudio.Linux.ProjectSystem.v2.LinuxRemoteDebugTargetsProvider.d__27.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.Linux.ProjectSystem.v2.LinuxRemoteDebugTargetsProvider.<>c__DisplayClass25_0.<b__1>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)
--- End of inner exception stack trace ---
---> (Inner Exception #0) System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.Build.Linux.Shared.RemoteTargetUtils.ProcessorArchToPlatform(String remoteArchitecture)
at Microsoft.Build.Linux.Shared.RemoteTargetUtils.ConnectionToDisplayNameShort(StoredConnectionInfo storedConnectionInfo)
at Microsoft.VisualStudio.Linux.ProjectSystem.v2.LinuxRemoteDebugTargetsProvider.d__27.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.Linux.ProjectSystem.v2.LinuxRemoteDebugTargetsProvider.<>c__DisplayClass25_0.<b__1>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)<---

===================

@braindeaddeveloper
Copy link
Author

I would note that I can see in project properties c/c++ all options : Additional Options : -I /usr/include
BUT in
project properties c/c++ command line : the -I /usr/include is missing

@braindeaddeveloper
Copy link
Author

I can confirm that -I /includepath into Additional Options :
project->properties->c/c++->all options : Additional Options : -I /usr/include
works and the -I ... is added to the remote command line

@itodirel
Copy link
Member

itodirel commented Sep 7, 2017

Reactivating based on activity; @braindeaddeveloper, we never been able to reproduce the problem you're seeing, regarding closing the issue, we have a policy on closing issues that we cannot reproduce on our side when there is no activity from the original author opening it after a certain time, there is nothing we can do in that case, as in this case we could not repro. Thanks for providing the additional information, we will investigate.

@itodirel itodirel reopened this Sep 7, 2017
@itodirel
Copy link
Member

itodirel commented Sep 19, 2017

@braindeaddeveloper regarding the exception that your seeing, could you open a separate issue for that? some questions about it, what is the version of Visual Studio that you are using? I'm looking for the entire version number from Help - About. Could you also tell me if your machine name, contains any columns, commas, dots in the name? Is it an IP?

@braindeaddeveloper
Copy link
Author

Hi Ion
Microsoft Visual Studio Professional 2017
Version 15.3.3
VisualStudio.15.Release/15.3.3+26730.12
Microsoft .NET Framework
Version 4.6.01055

Installed Version: Professional

Visual Basic 2017 00370-10000-02467-AA085
Microsoft Visual Basic 2017

Visual C# 2017 00370-10000-02467-AA085
Microsoft Visual C# 2017

Visual C++ 2017 00370-10000-02467-AA085
Microsoft Visual C++ 2017

Visual F# 4.1 00370-10000-02467-AA085
Microsoft Visual F# 4.1

Application Insights Tools for Visual Studio Package 8.8.00712.1
Application Insights Tools for Visual Studio

ASP.NET and Web Tools 2017 15.0.30726.0
ASP.NET and Web Tools 2017

ASP.NET Core Razor Language Services 1.0
Provides languages services for ASP.NET Core Razor.

ASP.NET Template Engine 2017 15.0.30726.0
ASP.NET Template Engine 2017

ASP.NET Web Frameworks and Tools 2017 5.2.50601.0
For additional information, visit https://www.asp.net/

Azure App Service Tools v3.0.0 15.0.30728.0
Azure App Service Tools v3.0.0

Common Azure Tools 1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

GitHub.VisualStudio 2.3.2.32
A Visual Studio Extension that brings the GitHub Flow into Visual Studio.

JavaScript Language Service 2.0
JavaScript Language Service

JavaScript Project System 2.0
JavaScript Project System

JavaScript UWP Project System 2.0
JavaScript UWP Project System

MenuCommands Extension 1.0
MenuCommands Visual Studio Extension Detailed Info

Microsoft Continuous Delivery Tools for Visual Studio 0.3
Simplifying the configuration of continuous build integration and continuous build delivery from within the Visual Studio IDE.

Microsoft JVM Debugger 1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft MI-Based Debugger 1.0
Provides support for connecting Visual Studio to MI compatible debuggers

Microsoft Visual C++ Wizards 1.0
Microsoft Visual C++ Wizards

Microsoft Visual Studio VC Package 1.0
Microsoft Visual Studio VC Package

Node.js Tools 1.0.0.0
Adds support for developing and debugging Node.js apps in Visual Studio

NuGet Package Manager 4.3.1
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

SQL Server Data Tools 15.1.61707.200
Microsoft SQL Server Data Tools

TypeScript 2.3.4.0
TypeScript tools for Visual Studio

Visual C++ for Linux Development 1.0.7
Visual C++ for Linux Development

Visual Studio Code Debug Adapter Host Package 1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

Visual Studio tools for CMake 1.0
Visual Studio tools for CMake

Visual Studio Tools for Universal Windows Apps 15.0.26730.08
The Visual Studio Tools for Universal Windows apps allow you to build a single universal app experience that can reach every device running Windows 10: phone, tablet, PC, and more. It includes the Microsoft Windows 10 Software Development Kit.

Web Extension Pack 2017 15.0.2
The easiest way to set up Visual Studio for the ultimate web development experience.

@braindeaddeveloper
Copy link
Author

braindeaddeveloper commented Sep 20, 2017

I can confirm there are no funny characters in the server name other than dots i.e.
server.domain.ext in this case:
abcd1234.company.com

@braindeaddeveloper
Copy link
Author

braindeaddeveloper commented Sep 20, 2017

Also I am not seeing an exception ...
I am not seeing the include paths :-)
which results in files not being found ...
If I take that remote command line and add the missing includes then run it remotely there are no "file not found" problems and the compilation succeeds.

@itodirel
Copy link
Member

itodirel commented Oct 9, 2017

@braindeaddeveloper could you open a separate issue for the System.NullReferenceException exception?

@ademyankov
Copy link

ademyankov commented Oct 13, 2017

I am seeing the same problem. Adding -I "$(RemoteProjectDir)/include" into C/C++->Additional Options doesn't work, g++ cannot find include files and the build fails!
If I specify the full path "/home/ademyankov/projects/test_app/include" then it compiles but as you can understand it is unusable.

@itodirel
Copy link
Member

itodirel commented Nov 9, 2017

@ademyankov regarding the relative path problem, that is a known bug and we are planning on fixing it soon @braindeaddeveloper is that the same problem you're seeing?

@braindeaddeveloper
Copy link
Author

@itodirel, @ademyankov ... no I was specifying full paths

@virooo7
Copy link

virooo7 commented Dec 28, 2017

I am facing the same problem with VS2015, replacing the relative path with the whole path seems to solve the problem as @ademyankov suggested.

@braindeaddeveloper
Copy link
Author

braindeaddeveloper commented Dec 28, 2017

I have updated to 15.5 and started a new project against a new linux host and its still happening ... doesnt matter how I add the additional include paths they arent passed over to the compiler on linux unless I specifically add them to the Additional Options field of the C/C++->Command Line property page.
I would note that they are identically specified/shown in the All Options read only field of the same page so they are understood by VS ... just not sent to the linux compiler.

gcc compiler : 4.83
linux host : Redhat 6.5
windows host : Windows 7

@braindeaddeveloper
Copy link
Author

So I have a question : is there a documented or undocumented flag I can use with VS or in the solution/project settings to show exactly what is being sent to the remote linux host ? Unfortunately I dont have the ability/rights to use netmon or any packet sniffers as its an investment bank and very tightly regulated.

@itodirel
Copy link
Member

itodirel commented Jan 3, 2018

We will need a repro, or if you like you can contact us directly at vcpplinux-support@microsoft.com. I would recommend trying to get a small repro that doesn't involve any of your IP and once you can repro, share the repro with us: logs and the project.

Yes. Please change the verbosity in Tools - Options - Projects and Solutions - Build and Run - MSBuild project build output verbosity, to Normal. And then when you build, you will see the compiler command line as this, in the Output Window:

1>  Invoking 'g++'
1>  g++ -c -x c++ /home/iontodirel/projects/ConsoleApplication6/main.cpp -g2 -gdwarf-2 -o "/home/iontodirel/projects/ConsoleApplication6/obj/x64/Debug/main.o" -Wall -Wswitch -W"no-deprecated-declarations" -W"empty-body" -Wconversion -W"return-type" -Wparentheses -W"no-format" -Wuninitialized -W"unreachable-code" -W"unused-function" -W"unused-value" -W"unused-variable" -O0 -fno-strict-aliasing -fno-omit-frame-pointer -fthreadsafe-statics -fexceptions -frtti -std=c++11

If you add an additional include, in Property Pages - Configuration Properties - C/C++ - General - Additional Include Directories, it will show up like this:

1>  Invoking 'g++'
1>  g++ -c -x c++ /home/iontodirel/projects/ConsoleApplication6/main.cpp -I /home/foo -g2 -gdwarf-2 -o "/home/iontodirel/projects/ConsoleApplication6/obj/x64/Debug/main.o" -Wall -Wswitch -W"no-deprecated-declarations" -W"empty-body" -Wconversion -W"return-type" -Wparentheses -W"no-format" -Wuninitialized -W"unreachable-code" -W"unused-function" -W"unused-value" -W"unused-variable" -O0 -fno-strict-aliasing -fno-omit-frame-pointer -fthreadsafe-statics -fexceptions -frtti -std=c++11

Note that currently the paths specified there, have to be absolute, remote paths, not local, nor Windows ones. The path above I added is /home/foo, notice the -I just after main.cpp above.

The limitation with the absolute paths is coming to an end, and we fixed that internally which will be available in the next release.

@itodirel
Copy link
Member

itodirel commented Jan 18, 2018

@braindeaddeveloper I created a video as a demo for this, would it be possible to take a look and tell us where it breaks?

Visual C++ for Linux Development - Setting up additional include directories

@braindeaddeveloper
Copy link
Author

Hi Ion ... I'm afraid that's blocked from work I will check when I get home. thanks

@itodirel
Copy link
Member

Hi @braindeaddeveloper did you have any success in configuring your includes?

@sraboy
Copy link

sraboy commented Feb 4, 2018

This is still an issue with relative includes on VS2017 15.5.6, with WSL as my build target. While the include files themselves are copied remotely and placed in their directories according to the project filters, the fact that the directories are referenced as "Additional Include Directories" appears to only affect Intellisense recognition and I'm required to update my sources to reference each include file by relative directory.

Unsure if it's related, but there appear to be issues with directories with Linux projects in general. I also had to fiddle with the remote output and debugging directories to get things to show up in the expected place. Part of the issue was that I was trying output files to $(ProjectDir)build\$(Platform)-$(Configuration)\ but that - was getting translated to a / so I had to change it to _ and part of it seems related to the fact that I use $(SolutionDir) in several places, which is one dir above the project, and causes some files to be copied improperly.

I eventually got things to properly copy remotely and launch GDB, though when the
compiled object files are copied back to my system (based on Linker settings), my hack of using .. in the remote path causes all the obj files to also be placed at .. relative to the expected location.

You can attempt to reproduce with the solution in this repo by building/launching the rapidtestlinux project.

@vgoldring
Copy link

vgoldring commented Mar 10, 2018

I have exact same problem with the latest version of VS2017, use absolute paths, and tried reinstalling it several times, including full removal. VS passes to Linux WRONG include directories, only some etc. The missing path shows up in the project's General and Command Line tab, but not in the command that runs over SSH. It also does not remove the useless Windows path mentioned above. That path was there from the beginning and is a complete mystery. The problem started suddenly yesterday midday without any (known) updates. Adding that missing absolute paths to Additional Options in Command Line helps. No angle brackets necessary, just -I /path.

@yuehuang010
Copy link

Hi @vgoldring , I am looking at the issue. In 15.7, we have revamped the translator between pc and linux. Can you provide examples of paths that is not translated correctly?

Here are few cases where translation are skipped.
Absolution path to missing directories are not translated.
Paths that start with '/' or '~/' are not translated.
Drive letters (C:) alone are ignored. (C:) is ok.

@vgoldring
Copy link

vgoldring commented Mar 15, 2018 via email

@vgoldring
Copy link

vgoldring commented Mar 15, 2018 via email

@yuehuang010
Copy link

Hello @vgoldring , I can't determine what has changed from the details provided. Could you please copy and paste the your Additional Option workaround and your input in Additional Include directories?

Until I know more, I can't provide detail on what regressed. VC++ Linux is actively being developed and even with the best of testing, regression are still possible. Preview time period allow us to take feedback and actively make fixes.

Once again. Thanks you for use Preview builds.

@itodirel
Copy link
Member

itodirel commented Apr 3, 2018

@vgoldring @svenbieg @braindeaddeveloper can you give us a repro, we are unable to reproduce what you're seeing; @vgoldring the solution that you attached would not help us, we need the project, if you can't give us the project, please give us a minimal repro; can you also tell us exactly the version of Visual Studio that you're using? You can get it from help about;

If you follow this video, can you tell us what you're doing different? Visual C++ for Linux Development - Setting up additional include directories

@itodirel
Copy link
Member

itodirel commented Apr 3, 2018

@vgoldring

More ambitious approach of automatically supporting full set of headers for Intellisense is implemented by VisualGDB, but took a long time to bring to a reasonably working state and I believe is still prone to breakdowns, particularly when moving or accessing a project from different PCs or to compile on different Linux machines. It also undertakes large, sometimes huge downloads of whole directories (not just header files) and may be time consuming on some networks.

You mean IntelliSense for remote headers? We implemented that feature in 15.7 Preview 2, if possible, can you try it, we are looking for feedback. We call the compiler, and automatically detect the headers on your Linux system, and download full directories back to Windows, and cache them. So you get IntelliSense for native Linux development, whether you're using the C or C++ standard library, or Boost, POSIX etc. We can even detect changes from apt-get, so if you apt-get install new development libraries, you can get them and have IntelliSense for it.

@vgoldring
Copy link

vgoldring commented Apr 3, 2018 via email

@itodirel
Copy link
Member

itodirel commented Apr 3, 2018

We do not have the project attachments.

@vgoldring can you gives us an example of an include path that is not passed to the compiler?

@itodirel
Copy link
Member

Hi, we are not able to reproduce, please let me know if there are any issues here, and I'd happily reactivate and look into it, we are trying to get the issue list number down, so tentatively closing

@svenbieg
Copy link

The command line option "-iquote projects/.." does work! But only with quotes " and slashes /!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants