⏱ Updated on March 7, 2017 to cover inclusion of Linux development with C++ workload in Visual Studio 2017, content edited for clarity and reduced reliance on images.
The Linux Development with C++ workload in Visual Studio 2017 enables you to author C++ code for Linux servers, desktops and devices. You can manage your connections to these machines from within Visual Studio. Visual Studio will automatically copy and remotely build your sources and can launch your application with the debugger. The Linux C++ project system supports targeting specific architectures, including ARM. Read on for how to get started with Linux C++ projects.
Today Visual Studio only supports building remotely on the Linux target machine. It is not limited to specific Linux distros, but we do have dependencies on the presence of some tools. Specifically, we need openssh-server, g++, gdb and gdbserver. Use your favorite package manager to install them, e.g. on Debian based systems:
sudo apt-get install openssh-server g++ gdb gdbserver
The best way to reach us is via our GitHub hosted issue list, directly via mail at vcpplinux-support@microsoft.com or find me on Twitter @robotdad.
This post is updated with content from update posts on this workload when they occur. As it has become lengthy here are the sections within this post.
- Installation
- Your First Visual Studio Linux Project
- Linux Project Properties
- Console window
- Linux IoT Projects
- How to use the VC++ for Linux with the Intel Edison board
- Desktop Applications
- Makefile Project Template
- Usage tips
- Reporting issues
- Changes
Installation
Launch the Visual Studio 2017 installer and start a new installation or Modify an existing one. In the Workloads selection screen, scroll to Other Toolsets and select Linux development with C++ and click Install. That’s it.
For Visual Studio 2015 you can download the Visual C++ for Linux Development extension or get it from the extension manager in Visual Studio.
Your First VS Linux Project
To get started create a new project by going to File, New Project then expand Visual C++, Cross Platform, Linux.
Today we have four templates available; Blink for IoT devices like the Raspberry Pi, Console Application as a bare application, Empty for you to add sources and configure from a clean slate, and Makefile to leverage your own remote build process.
Let’s get started by creating a Console app. By default, the Console Application is set to a debug/x64 configuration. If your remote target is x86 or ARM you will want to change those options first. We have a detailed guide on using the Windows Subsystem for Linux with the C++ Linux workload as well.
After creating your project from that template set a break point on the printf statement, then select the menu item Debug, Start Debugging (F5) or the Remote GDB Debugger button on the menu bar.
If is your first time targeting a Linux machine you will be prompted for connection information. This is triggered by building the project. We support both password and certificate based authentication, including the use of passphrases with certificates. Upon a successful connection, we save your connection information for subsequent connections. Yes, passwords/passphrases are encrypted when stored. You can manage your saved connections under Tools, Options, Cross Platform, Connection Manager. You can alternatively search for Connection Manager in the quick launch box in the upper right.
Upon connecting, your sources will be copied to the remote Linux machine, and we will invoke gcc to build the sources with the options from the Project Properties. After the build successfully completes, your code will be launched on the remote machine, and you will hit the break point you set earlier.
Linux Project Properties
Let’s look at the Project Properties to understand where things got deployed on the remote Linux machine. Right click the project in the Solution Explorer and select Properties to bring up the Property Pages dialog.
Looking at the General Property Page settings for the project, you will see the remote build root is set to ~/projects/ by default and that we are setting the remote project directory to match your project name in that location. If you look on the Linux machine, you will find main.cpp as well as your build artifacts in ~/projects/ConsoleApplication1. You can see how the output and intermediate directories were configured here as well. Additionally, you will see that this project was configured as an application, thus your executable is under bin/x64/Debug/ as ConsoleApplication1.out. Notice that for configuration types static and dynamic libraries are also supported.
Under the Debugging Property Page, you have options for controlling the debugger. Here you can specify things like pre-launch commands to execute before starting debugging, program arguments to pass, as well as more advanced options for finer control.
The VC++ Directories Property Page is where you would specify paths for additional headers to enable IntelliSense for your own libraries.
Copy Sources allows you at a project level to control whether Visual Studio should copy files. By default, this is yes, but if you are controlling this through other means this is where you can disable that.
The C++ and Linker Property Pages are where you can control the parameters passed to GCC.
The Build Events Property Pages enables you to specify additional actions to take during all stages of the build locally and on the remote target machine. Even more control is possible through the Custom Build Step Property Page.
Console window
The Linux workload has a console window tailored for interacting with your remote executables. This window shows not just the output of your program but can also take input. To activate this window, use the menu Debug, Linux Console.
Here is a simple program you can try these features out with.
#include <cstdio>
void log(char filename[], char visitor[])
{
FILE * pLog;
pLog = fopen(filename, "a");
if (pLog != NULL)
{
fputs(visitor, pLog);
fputs("\n", pLog);
fclose(pLog);
}
}
int main(int argc, char* argv[])
{
if (argc != 2)
{
printf("Please pass filename as input parameter\n");
return 1;
}
char input[20];
printf("What IDE are you using?\n");
scanf("%19[0-9a-zA-Z ]", input);
printf("%s! You can use that with me?!\n", input);
log(argv[1], input);
return 0;
}
Specify a filename in the Command Arguments input on your project’s Debugging property page. You can set a working directory on that page as well; if it is not set your home directory will be the working directory.
Linux IoT Projects
Now let’s look at an IoT device, the Raspberry Pi. You can use any type of Pi running Raspbian. For the blink sample wiringPi is required. If you don’t have this setup on your device already you can either install it via apt or from source.
Go to File, New Project and under Visual C++, Cross Platform, Linux select Blink (Raspberry). This template comes preconfigured to export the GPIO pin for the LED so that the executable does not need to run as root. Right click your project in Solution Explorer and select Properties. Look under Build Events at Remote Post-Build Events and you will see a command specified to run on the remote Linux target after build that does this.
Now connect an LED to pin 17 on your Raspberry Pi as shown here.

Open main.cpp and set a breakpoint on the delay call after the first digitalWrite and hit F5. You should see your LED light up and execution will pause at your breakpoint. Step through your code over the next digitalWrite call and you will see your LED turn off.
To enable IntelliSense for all of the libraries you have on your Pi follow the instructions below for copying your include files locally from your Raspberry Pi.
How to use the VC++ for Linux with the Intel Edison board
Using the VC++ for Linux extension with the Intel Edison board is largely like any other Linux system. First, you will want to make sure you have setup your device following Intel’s instructions. You should be able to connect to your Edison via the Visual Studio connection manager once you have connected it to your Wi-Fi network. If you need a direct connection to your Edison use these instructions for using Ethernet over USB with your Edison which will also work with the Connection Manager in Visual Studio.
The Edison makes it easy to start building an IoT application with sensor data. Accessories like the Arduino shield open make it easy to connect add-ons like the Grove shield from Seeed Studios. That shield lets you use any of the many available Grove sensors without having to worry about wiring a circuit on a breadboard, you can just get straight to your code. Intel has made this even easier to use with their UPM sensor library that covers a broad range of sensor including the Grove ones.
Shown here is an Edison compute module on an Arduino expansion board with a Grove shield attached and a temperature sensor plugged in.
In Visual Studio, create a new project, and under Visual C++, Cross Platform, Linux and select Empty Project. Make sure that you set your solution platform to x86 when targeting the Edison. Add a C++ file to the project and use the code from this Grove Temperature Sample from Intel. The UPM libraries are part of the default Yocto Linux image used on the Edison so no additional setup is needed to acquire them. You should change the include statement in the sample to properly reference their location as follows:
#include <upm/grove.h>
With that change, you are ready to build and run your code. You can see the output of this sample in Visual Studio’s debug mode in the Linux Console window.
To enable IntelliSense follow the instructions below for copying your include files locally from your Edison.
In a future post we’ll cover taking this sample further by connecting it to Azure IoT Hub.
Desktop Applications
We’ve covered headless and device Linux applications, what about desktop? Well, we have something special here: we’re going to launch an OpenGL app on a Linux desktop. First make sure your Linux desktop has been configured for OpenGL development. Here are the apt packages we used:
sudo apt-get install libgles1-mesa libgles1-mesa-dev freeglut3 freeglut3-dev
Create an empty Linux project and go grab the source for Spinning Cube from Julien Guertault’s OpenGL tutorial. Extract it and add main.c to your project. To enable Intellisense you will need to add the OpenGL headers to the VC++ Directories, you can get them from the OpenGL Registry or follow the instructions below for copying your include files locally from your Linux machine after you have installed the developer packages there.
Now open your Project Properties and on the Debugging Property Page add export DISPLAY=:0.0 to the Pre-Launch command. Under the Linker Input Property Page add the library dependencies: m;GL;GLU;glut.
Now hit F5.
A couple of interesting places to put breakpoints are around line 80 where the cube rotation is set (try changing the alpha value) or in KeyboardFunc where you can inspect the values of the pressed key.
Makefile Project Template
The Makefile project template supports using external build systems on your remote machine (make, gmake, CMake, bash script etc.). This works as you would expect under the C++ project Property Pages you can set your local Intellisense paths, then on the remote build Property Page you add the commands, semicolon separated, to trigger your build on the remote machine.
I have put together some bash scripts that can generate Visual C++ Linux makefile projects with your sources based on the directory structure. These scripts do assume that the source code on the Linux machine is in a directory that has been mapped to Windows. They do set the flag in the Project Properties to not copy files remotely. These are unlikely to meet all needs but should give you a good starting point if you have a large project.
Usage tips
In this section we’re going to provide tips on using the extension to make you more productive.
Verbose build output
We’ve gotten a lot of questions about what exactly are the arguments being passed to GCC. Our build output doesn’t make this obvious, but you can enable it. There are two ways to get to the same place to change this setting. In the quick input window search for “verbosity”, or under Tools, Options go to Projects and Solutions, Build and Run. Now for the option of MSBuild Project output verbosity change it to diagnostic to see everything in your output window when you build. This can really help you find what exactly was passed to GCC to build your program if you are having issues.
Getting your include files
Everyone loves IntelliSense, but we’re not yet synchronizing the include files from your Linux system. Everyone has their own ways to either share or copy these files which is great. I wanted to share a really simple way to accomplish this I used in prepping the next section on the Intel Edison. I simply grab the whole folder locally onto my Windows box using PSCP. If you are on Windows 10 and have the Windows Subsystem for Linux installed you can do the exact same thing using scp.
pscp -r root@192.168.2.15:/usr/include .
Now on your project properties go to the VC++ Directories page and add your local path.
Remote file copy management
It is possible to specify at the file and project level whether or not a file should be remotely copied. This means you can use your existing build mechanisms just by mapping your existing sources locally and adding them to your project for editing and debugging. You can change either on the Property Page Copy Sources, either select the project or the individual file in Solution Explorer and choose Properties.
Overridable C/C++ Compiler Path
You can override the compiler commands used on the remote machine in the Property Pages on the C/C++ General Property Page. That will enable you to point to specific versions of GCC if needed or even point to an alternate compiler like clang. You can use either full paths or a command available on your path.
Build Events
Under Build Events node of the Project Properties there are also pre-build and pre-link remote build events as well as options for arbitrary file copy in all build events to provide greater flexibility.
Debugging Options
In addition to supporting gdbserver we have a gdb mode to improve compatibility where we may not have the correct client gdb bits on Windows for the remote target.
You can also override the debugger command itself, this is useful for debugging external programs compiled outside of Visual Studio.
The Debugging Property Page has support for additional gdb commands to be passed to the debugger to run when starting debugging. One example of where this can come in handy is Azure IoT projects. If you’ve used the Azure IoT C SDK on the Raspberry Pi you may have run into seeing an illegal exception being thrown when you start debugging. This is caused by some interactions between libcrypto and gdb. You can find some discussion of this issue here. While debugging can continue you can avoid this error by passing an instruction to the debugger before it starts, in this case “handle SIGILL nostop noprint”.
Reporting issues
In addition to our support email alias, vcpplinux-support, VC++ for Linux has a public issue list on GitHub. This is a great option for having public discussion or reporting bugs. We have added our backlog for the extension here as well. You can see what we are targeting for a release by looking at the milestone tagged to an issue.
So please do follow our GitHub issue list and use it by either submitting feedback or +1 existing feedback there. We love hearing about how and where our extension is being used. Feel free to use our support email alias if you want to share that with us even if you don’t have any issues.
Changes
For Visual Studio 2017 we will post individual updates on new features as they become available and integrate content here as appropriate. We will also update changes in the Visual Studio change log as appropriate. For Visual Studio 2015 we will continue to post our change logs on the Visual Studio Gallery page for the Linux extension when it is updated.
Go Write Some Native Linux Code
We hope you are as excited by the possibilities this opens up as we are.
Install the Linux Development with C++ workload in Visual Studio 2017, try it out and let us know what works for you, what doesn’t or if you encounter any issues. You can reach us here through the blog, via the Visual Studio Feedback channel, or find our team @visualc or me, @robotdad, on Twitter.
– Marc Goodner
Post Changelog
March 7, 2017 to cover inclusion of Linux development with C++ workload in Visual Studio 2017, content edited for clarity and reduced reliance on images.
September 13, 2016 to include content from the 1.0.5 Update, added a TOC, and updated how to report issues.
June 17, 2016 to remove mention of a dependency no longer needed and pull contact info to top.
June 14, 2016 to include content from the 1.0.3 Update.



Great job!!!
This is awesome! I can’t believe it’s not mentioned or demoed in //build keynote today.
They tried to show a demo but the damn thing just didn’t work.
Yes, unfortunately it seems the network layer between the vm and host got confused. We should have set it up isolated. Not the way I wanted to learn that. :(
Do give it a try and let us know how it goes.
This is such an interesting and promising development. I applaud Microsoft’s steps towards a better community.
Very Nice!!!
Why use Visual Studio to develop rather than a text editor + SSH’ing and compiling? Genuinely curious.
Because Visual Studio is an *excellent* development environment. This is a pretty broadly acknowledged fact, even in circles that dislike Microsoft.
A visual debugger is excellent, the refactoring tools are much more powerful than a text editor’s can be, and having builds integrated tightly with your editor makes things *really* nice.
…but the debugger and buildsystem are not in VS in this case?
We are attaching the VS debugger to GDB on the remote machine, so you get the full experience of the debugger in VS. Similarly even though the code is being compiled remotely it is triggered and driven by the settings on your project in VS.
I installed VS2015 on E: drive. There is an error when debugging Linux code: could not find a part of the path ‘E:\toolchains’.
Thank you for trying our bits. Regarding the debugging error, we currently have a dependency on Android NDK, which comes from the C++ MDD tooling for Android, please install those components from the Visual Studio setup, more information on how to do that here https://www.visualstudio.com/en-us/features/cplusplus-mdd-vs.aspx. We are going to remove this dependency and make the setup self contained and independent, we just didn’t have time to do it but will do so in the coming days.
We removed this dependency in the latest update, and now installing the bits thru setup will be small and complete
Is it free alternative for VisualGDB?
I’m not familiar with VisualGDB, but yes, this extension as any C++ feature we ship is free, and it will work even on the Community Edition of Visual Studio.
It works a bit differently to VisualGDB in that you need separate projects rather than just configurations. So you have to manage two projects when you add / remove source files that need to be in both Windows and Linux builds. But on the plus side it is free.
Adrian, 1 for debugging, 2 for large projects say + 1.000.000 lines, it might handy with searching, X-referencing and untangling call-chains.
Looks like it crashes when trying to connect to the remote linux server
Same here. It crashes when trying to connect to linux server using private key.
I’ve tried with both private key and password. Only once it didn’t crash. The error message was about wrong host(‘ive inserted the ip of the machine) or port
the same,conneting and then crash,so how to let it work correctly?
Same here, crashes when I try to add a remote machine in the connection manager. I am trying to connect to an Amazon EC2 server running Amazon Linux.
We have a fix for the crash and we will publish an update to the extension in the coming days which fixes it.
Sorry guys, we’re looking at these reports and working on an update now. I’ll update this thread when it is ready, very soon.
Thank you! It’s very appreciated. I can’t wait to use it.
We have fixed the crash in 1.0.1, the latest update 1.0.2 has the fix also and a bunch of other features and fixes
Hi, it keeps crashing here, every attempt fails with a crash. I have updated Visual Studio 2015 (Update 2) and the Linux extension.
Do I have to reinstall everything?
Thanks
Hi, can you try the 1.0.5 release?
can i use it to deploy on raspberry pi 2?
That’s what is demonstrated above in the IoT section.
Yes, we even have a Blink template using wiringPi
Now does this work with the new bash on Ubuntu Linux running on windows – also just announced at BUILD?
i.e. Can you usual Visual C++ to compile locally on gcc on linux running on windows.
Seems to make more sense that using a remote linux machine.
We were focused on remote builds on Linux for our first release, so not today. We’re looking at what we should do in this area.
I mean maybe you could put some effort into Windows development, rather than Linux? Just saying.
Of course, VisualGDB has been doing this for some years now….
but Visual GDB isn’t free? :)
True, but it’s pretty cheap and also does embedded software. My point was more that this is not an amazing revelation.
It’s nice, and it’s included, and it’s free, and thanks, Microsoft.
I am so wet for Microsoft right now.
What ssh agent is being used in the Windows machine? VS embedded, or can putty be used?
The reason i’m asking is, i’m curious if Kerberos ssh authentication will be possible in the future?
We have our own implementation within the extension. Kerberos auth, I don’t know. I’ll look into it.
We do not support Kerberos currently, it could be supported in the future but we currently do not have such plans. Is it an important scenario for you?
What a case where we need to build on one machine and deploy and debug on different machine. How we can configure for such use case.
So compiling on a remote Linux machine and deploying to another Linux machine?
We do not support this scenario yet, but it’s something that is easy to do in our project system, and we’ll looking at enabling that soon.
Would really like that, to work on embedded projects, but compiling directly on those devices can be very slow and dependend on how you want to use this embedded device maybe even impossible.
Just to forgot to ask, are there any news regarding this feature?
I was already using VS to code Linux apps. You just made that awesome! Thank you!
Embrace.
Extend.
Extinguish.
This is a great step forward I am very pleased to see Microsoft do. However, as for the remote building on IoT devices, this is still impractical for any decently sized project due to long building time. True cross-compiling is a must in this scenario. Do you have any project for enabling true cross-compiling from within VS? Any idea of when that would be available?
Cross compiling is interesting to us, especially for devices. I don’t have any timelines to share yet but we are planning on updating this frequently. Is there a particular device you are targeting?
I do a lot of cross compiling for arm devices using eclipse in linux and i would love to get away from eclipse. it would be amazing if visual studio can use any cc toolchain or SDK developed in linux and use it create and deploy applications on embedded devices.
Stay tuned for our updates!
Can’t wait this weekend to try some neat programs on my Raspberry pi
Great plugin!
But we try to use
`pkg-config –libs gtk+-3.0`
as addition option in the command line of the linker. Unfortunately this does not work. The very same with
`pkg-config –cflags gtk+-3.0`
in the command line of the compiler works fine.
The linker error output is not visible.
We also ran into the problem that we cant see the linker output.
Its giving the following output in the visual studio output window
error : g++ exited with code 1, please see the Output Window – Build output for more details.
other than that, great stuff guys!
We fixed the problem with parsing the linker errors, and it is fixed in the latest update.
I had the same problem. solved it by adding `pkg-config –libs gtk+-3.0` to the Additional Dependencies of the linker instead.
The post focuses on C++/g++. Does this also support debug of C/gcc?
Yes.
when conneting to linux server, waiting… waiting…no response…then crash…restart vs…
how to fix it?
We have identified this problem and we have a fix which we will be publishing soon
Hi, thanks for trying our feature. We have a fix for the crash and we should be able to roll it out soon.
Our latest update should fix all of those issues
This is beyond exciting! Way to go Microsoft!
Ballmer 2001 prognosis; “Linux is a cancer”
This is awesome news, I hope I will be finally able to say goodbye to Netbeans.
I gave it a quick look and encountered few issues:
1. Can’t build Release version of my test project (which is just the default, hello world template that comes with the addon). I’m getting the following error: “C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Application Type\Linux\1.0\Linux.Common.targets(132,5): error : Element has an invalid value of “LineNumber”.” Debug config seems fine though. I’m using Debian Testing with gcc 5.3.1
2. Debugger output in VS does not capture program output, even though the ‘program output’ option appears checked in context menu
3. It would be great if the VC++ parsed all include files referenced by the project on *remote* machine. For instance, I have boost installed on my build host, but IntelliSense underlines all boost references in my source code. NetBeans is able to handle that somehow.
But anyway – I’m impressed.
+1 for the second issue
Thanks for giving this a try.
I’ll look into the first issue and see if I can generate a repro. The second is on our backlog. For the third we don’t support automatically bringing in the remote headers yet. You’ll need to get the boost headers on your local machine, add them to the additional VC++ Directories in the project properties and add the library references under the linker settings so we use them in the compile step. This is described in a bit more detail in the section of the post on desktop apps using OpenGL as an example.
At the moment I use the following code as a workaround for the second ‘problem’:
std::ofstream logStream ;
logStream.open(“/tmp/my_output.log”, std::ios::out | std::ios::app);
logStream << "This here\n";
logStream.close();
Use the 'logstream << "my text"' instead of printf.
And then use tail in a SSH session or in the display of the VM:
tail -f /tmp/my_output.log
It's a little ugly but it gets the job done for now.
Workaround for the first issue – change Debug Information Format in C/C++ General project settings to something else than the default ‘LineNumber’. Interestingly, after making the change first time, I no longer see ‘LineNumber’ option.
‘LineNumber’ shows up again after enabling ‘inherit from parent or project defaults’, so it’s looks like it’s defined in property sheets somewhere.
So, I installed the extension and added Boost to my project. Specifically, I’m using boost/asio/io_service.hpp.
Long story short: This file includes others.. that includes others… that include boost/asio/detail/config.hpp. However, config.hpp includes , and that file does not exist on C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\Linux\include\usr\include\linux.
The top error is:
Cannot open source file “linux/version.h”: \Boost\include\boost-1_60\boost\asio\detail\config.hpp 652
The full error: http://pastebin.com/3bGLdtkN
I can get this to work with boost library. I include #include , I get error boost/format.hpp: No such file or directory
Some answers. Regarding 1) we fixed this problem, but it was just after publishing the update. This fix will be in our next update. As a workaround you can set the DebugInformationFormat property to FullDebug or None, you can see how it is defined if you force change it in the Debug configuration, than copy that for Release. 2) We’ve working on this feature 3) This is an important scenario that is part of our planning.
I’m unable to connect to the remote server using password or key file. Each time I try to connect, Visual Studio crashes. Any suggestions?
Me too, crash every time.
the same
Same things happens for me. Happy to help if there are some new builds to test. I have been waiting a long time for this, I can wait a little longer I suppose.
Sorry about this. We should have a fix posted soon, I’ll reply when it is ready early next week.
Excited about this extension. Unfortunately for me it’s also a crash when trying to connect to Linux. Nice to hear that you are already working on a fix. Looking forward for it!
We have published new updates which should fix this issue
Thank you Microsoft. I have always been fond of VC++ IDE, but never really worked on windows. Great to see the bash and VC++ Support for Linux support.
When I tried add Linux connection, Visual Studio has crash. I updated Visual Studio 2015 to Update 2. Debugger message is “처리되지 않은 ‘System.UnauthorizedAccessException’ 형식의 예외가 PresentationFramework.dll에서 발생했습니다. 추가 정보: ‘C:\Users\<>\AppData\Local\Microsoft\Linux and IoT\User Data\1.0\store.xml’ 경로에 대한 액세스가 거부되었습니다.” by Korean. I guess it is File Access Denied exception.
We have a fix for the crash and we should be able to roll it out soon.
We have published a fix for this issue in the latest update
Tried to compile and debug a standard main.cpp linux project for ARM (raspberrypi) and got this error:
Severity Code Description Project File Line Suppression State
Error Length cannot be less than zero.
Parameter name: length linuxapp C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\V140\Application Type\Linux\1.0\Linux.Common.targets 36
I guess this is not usable yet at all.
Sorry to hear that. Did you connect as root by any chance?
Same problem, have you solved it?
Me too, same problem…
have you solved this problem?
This should be fixed in the latest update, can you try it?
Thats fantastic!
What about working with existing projects? lets say i have a makefile, or cmake project, can i use it with Visual Studio now?
I’m also interested in this, is there any further info regarding this?
Why not use clang as cross compiler, By default, build clang on Windows, clang is a powerful cross compiler, support x86 ARM PowerPC ….
You can add -isystem set SYSTEM directory ,–target= set target, and use -target link to elf file
clang version 3.9.0 (trunk 263866)
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: D:\LLVM\bin
For example:
clang++ –target=x86_64-unknwon-gnu-linux main.cpp -I”C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\Linux\include\usr\include\c++\5″ -I”C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\Linux\include\usr\include” -I”C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\Linux\include\usr\include\x86_64-linux-gnu” -I”C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\Linux\include\usr\include\x86_64-linux-gnu\c++\5″ -c
aslo, your can use clang as autocomplete tools
We have cross compiling in our backlog, and it’s going to be something we’re going to look at during next stages of planning
Great , Tks, I can give up on the Ubuntu development
Fantastic initiative!
I’ve a question in future will be possible to run C#/VB.NET/F# on Linux with this system?
Visual studio crashes for me too when I try and connect to raspberrypi2. I can connect using putty ok. I am using the example console project. Any suggestions to solve this welcomed.
We have a fix for the crash and we should be able to roll it out soon.
OK. Will keep a watch for update.
We have published a fix a few days ago that should fix those issues
Was able to build a project on my Raspberry Pi 3 and debug it. Very nice.
Only thing missing is the output from the program on the console.
Do you have a suggestion on how to handle printf output?
In response to questions about why one would use VS, spend some time developing large projects using Nettbeans, Eclipse, or Codeblocks and then do the same on VS. VS 2015 is far above these tools – I can not live without the ability to “peek” at a function or variable definintion after using it with VS2013 Pro.
Thanks for this.
Thank you for trying our bits! We are currently working on the console I/O which should allow you to see the program output and interact with your program
The latest 1.0.3 release adds a console window. See here on usage: https://blogs.msdn.microsoft.com/vcblog/2016/03/30/visual-c-for-linux-development/#consolewindow
Visual Studio crashes when new connection is added due to this exception:
—
An unhandled exception of type ‘System.UnauthorizedAccessException’ occurred in PresentationFramework.dll
Additional information: Access to the path ‘C:\Users\\AppData\Local\Microsoft\Linux and IoT\User Data\1.0\store.xml’ is denied.
—
Even when you create empty file, it still fails because the file is deleted first before writing.
It would be great if you can provide an example of the XML file, so we can edit it manually while we’re waiting for the fix?
We have published an update which fixes this issue
Fantastic Tool. Got it up and running pretty easily and it seems to work fine. Just one question that I may well be missing the really obvious answer. Where does the console output get directed? For example, if I create a simple console application following the instructions above and compile on my Ubuntu machine. When I set a breakpoint and run it in the debugger, everything works as advertised, but I can’t see the console output anywhere, either on the ubuntu machine, or anywhere in Visual Studio or on my windows machine. The Debug Output window in Visual Studio seems to show some output from GDB startup, but not the output from the console app itself. Obviously if I run the built executable on the Linux machine everything is fine. Any thoughts?
Getting console output locally is on our backlog. We weren’t able to get to it for the first release.
Understood, I’ll keep my eyes peeled for the next version.
One other question. Again, if I set up the basic console demo, I can compile fine on Debug, but with Release I get the following error:
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Application Type\Linux\1.0\Linux.Common.targets(132,5): error : Element has an invalid value of “LineNumber”.
Sorry about that, this is a bug we recently discovered in the Release configuration. We made a fix but it so happened after we published the latest update, 1.0.2. The fix will be in the next update, but as a workaround, you could set the DebugInformationFormat property inside the vcxproj to FullDebug or None, you can see how it is defined if you force change it in the Debug configuration, than copy that for Release.
hello, if i want to link library file under linux (such as : libprotobuf.a), how to link? copy to the windows from the linux?
Look at the desktop section in the post, it describes this using opengl as an example. Basically you need to get the headers locally for intellisense, specify their location in the project properties, and specify the libraries you are using on the linker input project properties .
A littlebit late ?
I am sorry for asking potentially stupid questions.
Is it possible to set up Visual Studio 2015 with the Visual c++ linux extension in vmware workstation vm? I noticed some cross-platform Android packages had to be installed, and if Hyper-v has to be enabled I can not run both hypervisors on my regular OS.
Also, what would be the prerequisites for developing qt or wt applications from Visual studio ? When I asked the people at WT if it would be possible compiling WT applications in VS for linux, and referring to this article, they responded :
“That may work, but the article is quite silent on what happens with dependency header files and libraries etc. Probably you’ll need to build wt on the target system first (using the traditional method), and then create such a linux project in msvs. Building Wt itself will probably not ‘just work’, because we use cmake to search for dependencies and to create the sln, and I don’t think cmake suports this configuration.”
What are the obstacles there you think ?
You can build the project from within a VM. I would not expect to get X output on my Windows dev system in a VM but I’ve not been able to get an X window to show on my windows desktop on a stand-alone machine either.
Now, if Marc is reading this, IMO capture of the remote display is unnecessary in a VM environment and of secondary importance with stand-alone machines. We’d be perfectly happy having the Linux application display and interact on the Linux desktop, or other display device. The important thing is to fully exploit the capabilities of the Visual Studio. And this should be possible in any environment.
I can confirm that is not working! It crashes with it tries to create a new connection for me too…
I really hoped to have finally a working IDE for C/C++ for Linux but it seems it is not yet the time yet! VIM forever?
Eclipse is a whole lot better than vi.
They might have jumped the gun on this release but I guess they wanted something to show at Build. Let’s hope the flood of responses prompts MS to see it thru.
We have fixed the crash and the latest updates 1.0.1 or 1.0.2 have the fix. Can you try the latest update?
Installed 1.0.6.
connection manager just freezes, while connecting to the server. its been like 30 mins.
can ping the server through powershell, server responds.
Logged in through mobaXterm.. no issues..
Putty works.
@fano123 : yes it is VIM and bash scripts forever. never failed and never will.
I have my setup with screen sessions and my environment setup, and guessing the time it takes with these IDEs.. I am at peace with my terminal. :)
This is very exciting and seems to really underscore Microsoft’s long-term efforts to broaden its appeal among diverse development platforms.
Very nice.
Wasn’t able to get the desktop spinning cube to execute via remote gdb, but was able to open a terminal on my linux vm, navigate to the project output folder then type the DISPLAY=:0.0 and ./SpinningCube.out commands to get it to run.
Looking forward to seeing this improved.
Did you set the display command in the Property Pages – Debugging – Pre-launch command?
You have to set “Pre-Launch Command” to “export DISPLAY=:0.0” . Maybe you forgot the “export”? That was my mistake when I followed this tutorial.
This is so cool. Too bad it doesn’t work.
I tried hello world.
It compiles.
When I want to debug, I get “Could not find a part of the path ‘C:\toolchanis'”.
1. This error message doesn’t make any sense for me.
2. I did a little bit of research and you gusy claim that there is a dependency betwwen some sort of Android Tools. I installed themfrom the verrybegining but it still doesn’t want to work….
We have removed the dependency on the Android bits entirely, can you try the latest update?
Well, I have tried it, and it works!
But:
1. Copying all the sources to the remote system doesn’t looks secure.
2. And it could take significant time on big projects.
3. And the target machine could just not have enough space to keep the sources and intermediate files.
One more thing, I cannot see the output of my console application, but I hope this is probably just a matter of time and you will implement it soon ;)
Regarding 1) this happens over a secure encrypted channel so why the concert? We’re also planning cross compile, would that help here?
2) We’re working on improving this, we know it currently it is less than ideal.
Cross compile will be a great solution.
You use an encrypted channel, but the encrypting gives an additional load to a build server. If you have a lot of big projects this can be an issue. If you have a couple of small project then an additional build server is the waste of resources.
Is it possible to ignore the error “The remote project directory ” is set to a system directory. This can cause harmful behavior and is not allowed.” ? Or mark some directories as user (not system)?
We have fixed this in the latest update.
It doesn’t work, at least for me. I have installed the last available version, but stil got the same error message:
‘/home/luke/projects/ConsoleApplication1’ is set to a system directory. This can cause harmful behavior and is not allowed. ConsoleApplication1 C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Application Type\Linux\1.0\Linux.Common.targets 42
I’m using Visual Studio Professional 2015 (14.0.23107.0 D14REL) and trying to connect to Oracle Linux (Linux 3.8.13-68.1.2.el7uek.x86_64).
Moreover in the “Remote settings” of the project I’m not able to select previously defined connections. But seems that I’m able to connect to remote target (for example I can see something like “Current project architecture ‘x64’ is compatible with the remote machine architecture ‘x86_64′” in the Build Output).
I tried and I am also getting the same error.
The remote project directory ‘/mnt/sequoia/linux-home-01/Users/spr/projects/ConsoleApplication3’ is set to a system directory. This can cause harmful behavior and is not allowed. ConsoleApplication3 C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Application Type\Linux\1.0\Linux.Common.targets
Will you please point me the version in which this is fixed?
Thanks,
Siva
+1 in latest version! ‘/data1/mm64/wuyao/Project1’
what is system is set to a system directory?
Hi,
How do you start the remote debugger (gdbserver) in Linux? I assume that it must be started to accept connections from the VC IDE.
Thanks,
GT
We start it with gdbsever :portnumber, the port number is user configurable from the Property Pages – Debugging section. By default it is empty, and we start from port 4444, until we find an empty port which we use for listening on. The connection with gdbserver itself is tunneled thru SSH
I can confirm that the April 5th update solves the problem I was having with Visual Studio crashing when attempting to connect to my Linux host.
Seems to all work as advertised!
Thank you
i have a question.
i tried & success g++ build on visual studio 2015.
i can build & run, debug.
but i don’t see a stdout message.
how to see a std::cout message on windows?
i look a debug output. but there is not show stdout message.
We’re currently working on adding a console I/O Tool Window
I could connect to Linux machine and build test project (ConsoleApplication1) but when I tried to run it, VS showed error message box “Unable to start program ‘app-process’. The file name, directory name, or volume name label syntax is incorrect”
Everything was as default, I did not change any build/debug/run parameter.
May be you could help me?
I have the same problem (same error message as John) each time I “Start without debugging”. “Start debugging” works fine, however. The program is a minimal “hello world” which compiles OK and can be run from the putty console without a problem.
I have this same problem as well.
Not working for me. Add connection cause the VS cause.
We have fixed this issue in the latest update
Nice Article ! Thanks.
Hi,
Great plugin this we have been waiting on for long, so we can do development on and compile for another. However, the ssh connection is refused, I tried the same credentials in putty and notice I needed to accept a certificate to be able to connect. Would it be able to push a similar issue into the extension?
Thanks guys!
You can connect using password authentication or private key authentication. For private key authentication we only support openssh formatted keys. Puttygen can do this key format conversion.
Really cool. Compliments
great job, i really love this tool, but something unusual occur wheni added files into the solution can compiled, it showed the following error:C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Application Type\Linux\1.0\Linux.Common.targets(50,5): error : No such file
what does it mean?
thanks,looking forward to the next version.
We have fixed this issue in the latest update.
Will you please provide me the link to update which has this fix?
Thanks,
Siva
Nice Article ! Thanks
I applaud Microsoft’s steps towards a better community.
http://www.iransaffrons.com
I got this problem while I was testing it with a Linux console app:
\MSBuild\Microsoft.Cpp\v4.0\V140\Application Type\Linux\1.0\Linux.Common.targets(36,5): error : Length cannot be less than zero.
Anybody can help me?
This should be fixed in the latest update, can you try it?
Great post
Works perfectly.
I have a question:
How to add and compile or another library?
THX!
You mean additional include directories? You can do that in Property Pages – C/C++- General – Additional Include Directories. This takes both local include paths for IntelliSense and remote paths for build. You also have access to the command line, where you can add anything to. You can also configure the libraries you link in Linker – Input – Library Dependencies
This is pretty awesome.
Using Win7, VS 2015 Community, Fedora-23
The Desktop application did not work for me. (The hello world example did.)
There are a lot of compile errors starting with
cannot open source file “GL/glut.h”
The output window has this
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Application Type\Linux\1.0\Linux.Common.targets(180,5): error : g++ exited with code 1, please see the Output Window – Build output for more details.
But I can’t find the Build Output from g++
compiles just fine on the target machine.
thanks
My fault. I set the libraries for the release project and ran the debug project.
Thanks! We fixed the diagnostics in the latest update, so now linker errors show properly in the Error List.
When I do this, I get the error “gdbserver failed to debug”. It successfully connect to my Ubuntu 14.04 server, created the folder, and compiled the “hello world” sample.
Same here. Did you figure it out?
Ah, project name: “hello world” … no space in projectname allowed
Thanks, I’ll try this out after installing the latest update.
Ion, any chance of getting this fixed?
Is there a way to add linux compilation as just another target of an existing project? We have cross-platform project, which builds on linux and windows, currently with WinGdb we just have a separate target, and everything works.
I’m not sure what you mean by a different target? Could you create two projects each building for each platform and referencing the same sources?
Such a nice feature!I’m just wondering how to include in my solution some specific headers, in my case unistd.h, or i2c-dev.h because i’m using a Jetson TK1 with ubuntu trusty arm?
Hi, any idea why the remote gdb debugger process would throw “Unable to start program ‘app_process'” when the remote connection is just plain x86 Ubuntu? The files are all deployed and built and runnable on the remote, but just can’t launch the VS debugger.
local Config:
VS2015 community 14.0.25123 update 2
vc++ for linux dev 1.0
new Console Project (Linux)
remote:
ubuntu 15.04 x86 (virtual machine)
openssh-server g++ gdb gdbserver installed ok
thanks
You must be hitting the ctrl+F5 for running the code, but you should understand you can only run the application on LINUX.
The correct way to run it is to press F5 or click Remote GDB Debugger, which the application will run on the linux
Is there a plan, to make MS frameworks, like ATL/MFC at least in parts availabel on Linux also?
This would ease cross platform development or at least make porting of code easier.
What about using native linux libraries or platform dependent libraries? How could one go about that?
I am trying to use VS Community to develop for the Raspberry Pi using an external library, but I’m having trouble:
1. The library works perfectly fine using the property sheet when developing for my Windows 10 machine. It builds and executes.
2. I can cross compile both into my Ubuntu Virtual machine and my Raspberry Pi (without the library; simply using cstdio). They build and execute (prints the “hello”).
But I cannot get VS to use the external library. It’s the same property sheet (I simply copied it across), but trying to include the same header file using the same line causes a “cannot find header file” error.
Any help at all is appreciated. Thank you.
Hi, great job!!! Found time to play around a little and ran into questions/problems. First prog as usual: “hello_linux!”. So I set up a console prog, it compiled, no probs.
– tried to step over (F10) the printf(“hello linux”); But this ended up in asm-Code. (a strcpy() was stepped over as expected)
– Shift-F11 (execute to next return) does not work as expected: single steps thru code
– where are the printf results (have to admit: I was not logged in to the Ubuntu. Nedd I log in?
Either way: great, great job!!
Hello,
I can run and debug app, it’s ok. But i have “namespace “std” has no member “cout”” and same for std::string type(but compile works well).
How can i fix this ?
There is solution of “LineNumber” error:
1. Go to :\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Application Type\Linux\1.0/ Make reserved copy of Linux.Common.props.
2. Edit file Linux.Common.props: find line 124 (like this: LineNumber).
3. Change LineNumber to None (new version: None).
4. Save changes. Compiling without error.
:( Blog remove all xml lines.
First of all, thank you for this fantastic tool. I have a question using this tool. When I debug a console application, how can I see the output in the linux
hi,
thanks for this, great stuff. trying to port one library using the current available msbuild project files and get this error:
1>Target “ClCompile” in file “C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Application Type\Linux\1.0\Linux.Common.targets” from project “D:\prod\kits\toolkits\datalib\datalib.vcxproj” (target “_ClCompile” depends on it):
1> Using “MakeClCommandLine” task from assembly “C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Application Type\Linux\1.0\Microsoft.Build.Linux.Tasks.dll”.
1> Task “MakeClCommandLine”
1> Done executing task “MakeClCommandLine”.
1> Task “MakeClCommandLine”
1> Done executing task “MakeClCommandLine”.
1> Using “Compile” task from assembly “C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Application Type\Linux\1.0\Microsoft.Build.Linux.Tasks.dll”.
1> Task “Compile”
1> Starting remote build
1> Compiling sources
1> Invoking g++
1> g++ -c /home/xxxxad.xxxx.com/user/projects/datalib/allocator.c /home/xxxxad.xxxx.com/user/projects/datalib/data_common.c /home/xxxxad.xxxx.com/user/projects/datalib/datalib_release.c -I .. -I ..\lib1\interface -I ..\lib2\interface -I ..\lib3\interface -I ..\lib4\interface -I ..\lib5\interface -I ..\lib6\interface -I ..\lib7 -I ..\lib8 -I ..\lib9\interface -g0 -o “/home/xxxxad.xxxx.com/user/projects/datalib/../ObjDrop/toolkits//Debug/x64///” -Wall -Wswitch -W”no-deprecated-declarations” -W”empty-body” -Wconversion -W”return-type” -Wparentheses -W”no-pointer-sign” -W”no-format” -Wuninitialized -W”unreachable-code” -W”unused-function” -W”unused-value” -W”unused-variable” -O0 -fno-strict-aliasing -fomit-frame-pointer -DNT -DOS_NT -DWIN32 -D_MBCS -DANSI_HEADER -DUSEdatalib -DNDEBUG -fthreadsafe-statics -fexceptions -frtti -std=c11 -x c -D_SCL_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS
1> allocator.c
1> g++: warning: ‘-x c’ after last input file has no effect
1> g++: fatal error: cannot specify -o with -c, -S or -E with multiple files
1> compilation terminated.
From what i see the MakeClCommandLine runs only twice in my case causing the first g++ to try to compile multiple files, if creating a new Linux project the MakeClCommandLine target runs once per file? This is confirmed if i add the old files into a new Linux project, then a i see many more MakeClCommandLine.
This looks related with some of the existing build options. but i have no idea which.
thanks for the help
Hi,
I have downloaded visual studio 2015 and also the linux cross platform extension for c/c++.
I can connect to my VM debian linux fine using putty or ssh (cygwin). However, in visual studio when I put in the IP address and the port 22 it doesn’t connect.
In task manager I see this program — “connect to Linux device”
How can I debug what is the problem with connecting to the linux VM?
regards,
Yogesh
When using this I enter in the SSH connection information when prompted. The textbox for the IP address and sometimes port number have their border turn red. I can connect with Putty using SSH without any issues so I know the information and network are valid. This plug-in doesn’t give me any error information to report on. I really hoping this plugin works since I currently use VisualGDB and would like to dump it because using VisualGDB with TFS is kind of cumbersome.
Howdy! Good stuff here. And timely too! Thanks.
How would one go about specifying command line arguments to launch the remote with? I couldn’t find anything of the sort in the Debugging section nor anywhere else in the project properties.
This capability was added in the 1.0.3 release last week.
Hello,
I have two more issues, or maybe rather enhancement requests:
1. All source files are always copied to build host. This takes time, especially if you have Raspberry PI on the other end… and it’s on wifi. Also, all source files seem to be recompiled each time I build, which takes even more time.
2. I don’t see a way to enable multiprocess compilation. Did I miss it, or it’s not available?
Here’s how NetBeans handle these:
1. Only modified files copied to the build host. Also, they are zipped up on the dev host which seems (I did not measure it) to speed up the transfer. Only files that need compilation are recompiled. make figures this out
2. Multiprocess compilation can be enabled by adding -j switch in make options in project settings
I hope you can implement these soon, it would really make remote builds way faster.
wonderful!
I like you, man.
but I have some question:
1. I create a empty linux project, and I add my cpp file, when I build it, its giving the following output in the visual studio output window
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Application Type\Linux\1.0\Linux.Common.targets(169,5): error : g++ exited with code 1, please see the Output Window – Build output for more details.
How can I fix it, or where is the “more details”?
2. Can I attach to the progress which already started in linux, like remote debug?
Dear zhang,
did you fixed this problem and how?
When I create a C++ project with a ubuntu 14 as the build server, I get three different issues
a) Code builds fine and runs fine but the Visual Studio editor shows various redlines in code like: cout not defined , std::mutex mtx; not defined etc. Is it just a matter of pointing to the right headers? Note: My VS is ok, local projects don’t have this problem. Only Linux projects have this.
b) When debugging, I am unable to see the values of any std::string variables in the debugger local vars or the watch. I can see some other vars like ints.
c) I can’t see any console output. Is that a work in progress or I’m missing something here?
I am planning to use this for some serious work so any help will be greatly appreciated!
Thanks!
What about supporting the build on Linux in Team Foundation Services Build vNext?
I tried a sample hello world sample program.
When I try to build it I get following error:
Error g++ exited with code 127, please see the Output Window – Build output for more details. ConsoleApplication7
If I login to remote Linux box and just run
g++ main.cpp
it runs fine and generates a.out
Whats the issue here ? As output from build is not clear enough..
Path for g++ on remote Linux is
/opt/sor/tools/gmd/tools/gcc-4.5.3/bin/g++
When I changed file “C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Application Type\Linux\1.0\Platforms\x64\PlatformToolsets\Remote_GCC_1_0\Toolset.props” to change /opt/sor/tools/gmd/tools/gcc-4.5.3/bin/g++
It gives now error
error: /opt/sor/tools/gmd/tools/gcc-4.5.3/bin/g++ exited with code 1, please see the Output Window – Build output for more details.
I’m not sure where to report this bug but I am experiencing one and it occurs under these circumstances;
1. Add two projects, A then B.
2. Add a file to both projects with the same name.
3. Add a call to a function within B’s version of the file.
4. Debug project B and breakpoint on the call to the function
5. Attempt to step into the function.
Now project A’s version of the file will be open on the line it should be stepping into for project B. This makes it impossible to debug some projects with this extention.
We use CMake to manage our projects. Is there a way to get CMake on windows to generate a Visual Studio for Linux project, or is there a way to get Visual Studio to use CMake & make on linux for building?
I might be wrong, but I don’t think this is possible. They use a custom project in Visual Studio, they don’t use or create a make file. Also, I don’t think CMake can generate a Visual Studio project file, I think these project files a specific to VS! What I will do is create and debug the project in Visual Studio, then create a separate make (Makefile). I will add the `Makefile` to my Visual Studio project so I can edit it directly in Visual Studio. The Makefile only really needs to build the Release version, because you can/will do all the debugging in the Visual Studio Debug build. So I will add the `Makefile` directly to my Visual Studio project, and edit it in Visual Studio, and copy it to the live server with the source code. I’m not using Visual Studio on my live production server yet. I only use it to develop and debug on CentOS running in VirtualBox on my development machine. Then I will copy/upload/git/svn the code to the production server when it’s ready!
Many thanks for a brilliant toolset. Here is my challenge. I am building an app for my Pi 2 and am trying to abstract some of the common elements into a static library. My solution has a library project based on Blank App for Linux and an executable again based on Blank App. Have added a reference in the exec project to the library project. Compiled the library – worked a treat. Tried to compile the executable and found that the reference was ignored and won’t compile. In such a scenario, how would one srtup the projects? Do we have to compile and deploy the library and copy header files back into the executable project, provide a library dependency and then try compile?
Is it possible to attach VS debugger to GDB runnning in Linux machine? Or maybe to start gdb with specified parameters to debug application built in Linux.
Consider following scenario: you have built some complex linux application with cmake of scons on Linux but you want to debug it using Visual Studio. Is that possible? Or maybe it will be possible in future releases of Visual c++ for Linux development?
This plugin already attaches itself to GDB running on the Linux server. I have a CentOS server running in VirtualBox on my Windows desktop, I setup SSH and GDB server on the virtual server running on my desktop. Then I use Visual Studio and this extension to connect to the virtual machine, it compiles the source code and executes the file, and I have Linux Console directly in Visual Studio.
I’m going to add a `Makefile` (like `cmake` file) directly in my Visual Studio project. So I can use Visual Studio to edit the file, like a normal text editor. Then I will VS on my desktop and virtual machine to test and debug the software. When I’m done testing and debugging with Visual Studio, I will edit and test the Makefile and upload that to the production server, and use the Makefile to build the project on the live production server!
If some one wishes to be updated with latest technologies afterward he must be go to
see this website and be up to date every day.
Look great! However I have some problems debugging with Remote GDB Debugger with Hello World Project.
The linking is fine, but in …/obj/x64/Debug/Project1.log:
Linking objects
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Application Type\Linux\1.0\Linux.Common.targets(180,5): error : g++ exited with code 4, please see the Output Window – Build output for more details. -> but there is nothing except linking phase succeeded.
Especially when I tried to debug, an error message popped up with “gdbserver failed to debug”.
I got into the target machine, the .out file is there and can run okay.
Do you have any idea what happened and how to see more detailed logs? Thanks!
Ah it’s alright no prob. My gdbserver got problem with ptrace.
Great job guys. I got the “Hello World!” done faultlessly on the first try.
1) I can build Hello World project okay but still have some concern regarding linking more complicated projects.
I compiled the files in VS, and if I link object files in the remote machine by hand it works, but not from Visual Studio host machine.
Let’s say project A needs to link with boost_python to work.
In the setup of project A, I need to specify locations of boost_python on both local and remote machine?
Is this boost_python library need to be the same file? Or on host machine it can be .dll and remote machine .so file?
2) Also, do you have plan to change verbosity level of build process? I think you have mentioned about ‘lastest update’ but where it is?
3) It would be really helpful if the configurations setup is separated into host machine and remote machine. It’s hard to understand which option is used for which.
Thanks much!
I can’t find “Templates > Visual C++ > Cross Platform > Linux” option in vs2015 community.
`Templates` is under the section called `Installed` on the left side:
File -> New -> Project
Then on LEFT SIDE of `New Project` window:
Installed -> Templates (a section on the left side under `Installed`) -> Visual C++ > Cross Platform > Linux
Is there a possibility of support freebsd?
Any chance of open-sourcing this extension?
I believe they do plan to open source it!
Connection Manager doesn’t work, neither with password , not with key authentication.
Visual Studio 2015 Update 2
Make sure you can connect to the machine! From command prompt try something like:
telnet 127.0.0.1 22
or whatever your IP address is … This should come up with an OpenSSH message, then you know you can connect! Then use those settings in the Visual Studio plugin! If you cannot Telnet into the server, then you have done something wrong on the server setup! Maybe there is a firewall blocking port 22.
Error unrecognized command line option “-std=c++11”
This is the compile error i get when I follow the example above and create empty console application..
.
And why did i have to install android sdk under cross platform, when I only wanted linux..
Now I have linux and android installed..
This sounds like you have an older setup of the extension, we removed the prereq on the Android tools in our second update. Can you double check that you have the latest extension installed?
Awesome job, dev team! I have a question – can I use this superb tool for projects I have already configured with CMake?
Unfortunately no, we have a unique project system for this to enable the remote connection settings we need to the Linux machine.
can you help me to solve this problem
Nice! I has used visual studio for years But I am new to C++ development on Linux.
After Successfully connect to Linux, Vs Popup a window , it shows ” Could not select a local port for communication with gdbserver”.
I don’t know how to solve this problem.
Hi, sarthakpati, our latest release of the extension, 1.0.5, can target CMake using Makefiles projects. Please give it a try and let us know if it works for you or if you have any suggestions.
axidaka, I believe we fixed this in the latest release, can you give it a try?
my home dircetory is on “/data1/mm64” which cause this error.but i am sure that my home directory is safe to do everything.
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Application Type\Linux\1.0\Linux.Common.targets(42,5): error : The remote project directory ‘/data1/mm64/wuyao/biz_linux’ is set to a system directory. This can cause harmful behavior and is not allowed.
Hi, we fixed this in the latest release of the extension, 1.0.5
Hello,
I try to get the Raspberry Pi example running. It compiles, transfers the sources, but then it fail to start the GDB. I can only connect to the Pi with the actual IP rather than by the name “raspberrypi”. As far as I can see the GDB setup fails to be recognized if it is an IP address instead of a name.
Does anyone know how to slove this issue?
The idea is great and seems to work in general, but it breaks down when trying to tweak project settings and dependencies.
For example, in project settings C++ Additional Include Libraries are difficult to set right because it seems Visual studio strips away all folders picked manually and does not pass them to GCC. It makes sense because the paths (also in Windows \ format) do not exist on the remote server, but it would be great to resolve them relative to the project root.
If I enter the paths in *nix format with / they are passed to GCC but obviously the paths are not right because when launching GCC, current directory is user’s home and not project root directory. So, to make C++ Additional Include Libraries and also (linking libraries) to work, Visual Studio should know how to resolve $(ProjectDir) when passing arguments to remote GCC.
As a workaround, it would be nice to be able to specify GCC working directory to resolve include paths relative to the project.
Also it would be great to configure VS to stop copying the files to remote system in case if I’m developing directly in a shared folder.
Of course, cross-compile would be even more awesome…
Is it possible to create a portable library (like “Class library (portable)” for C#) that both build a Windows binary and a Linux binary?
Hi, this extension targets specifically C++ and Linux, so it cannot target C# currently. I can relay your message to the C# team, and they can provide a better reply here.
I’m following this project and have to say it’s great and promising.
I want to make a suggestion or a feature request. article mentions copying source usr/incude directory to projects directory in order to have intelisense. that’s great, but can we not satisfy ourselves only with that and add an optional feature to run preprocessor locally then transfer reprocessed single source code to the remote machine.
I think that will accelerate building and transfer speed as well. and will be useful for building very huge projects(say if transfer would be compressed, and then decompressed on the remote machine)
This is the best thing I’ve ever seen. Great job! Visual Studio is insuperable.
Guys, I’ve sent you a complimentary email, I cannot thank you and congratulate you enough! I think this could be the most influential plugin in the world! It’s absolutely amazing! It’s the biggest pain in the world to have to switch between 2 or 3 IDE’s for my work. Visual Studio for my front-end and Codeblocks/Netbeans/Eclipse/KDevelop for my Linux (CentOS) back-end work. What an amazing job! I’ve waited 20 years for this! I thought Cygwin would be answer to my cross-development woes, but this is incredible! Being able to compile and executing this code on my CentOS VirtualBox; directly on my development desktop machine; and having a Linux Console directly in my Visual Studio just blows my mind!
OH, I have a suggestion. I would like to have the ability to open a Linux Console to the machine, not the debug console, a regular console in Visual Studio to the same machine, same connection as the debug one! So essentially you will have 2x Linux Consoles … the `debug` one where the GDB application is running, and another one for regular console commands. So I execute things like `top` or whatever. Just a `nice-to-have`. But great job on this guys! Truly amazing!
Hi, is there any configuration to run some command line BEFORE the compile starts but after files are copied? Some of my files may need conversion.
Nice! I has used visual studio for years But I am new to C++ development on Linux.
After Successfully connect to Linux, Vs Popup a window , it shows ” Could not select a local port for communication with gdbserver”.
I don’t know how to solve this problem.
Thanks for your great job . and it can’t work well in my case.
it always show the Errors “g++ exited with code 1, please see the Output Window”.and I can’t find any error in my code. it was just a “hello word” to test remote Compile.
what make me confuse is that i can’t find more details about this Errors in Output Window and the plugin worked well before the “compiling source” stage.
the following is my environment:
local: windows 10+Visual studio 2015
remote: fedora 14+ linux 2.6.35.13 + gcc 4.5.1 + gdb 7.2-16.fc14 + gdbserver 7.2-52.fc14
Hi
I need change the compiler name for use with differents toolchains. And I want to use gcc not g++. How to make this? I not found where change this in the property page.
Thank you very much!
The latest version of the extension, 1.0.5, supports this. In Property Pages – Remote settings you can change your tools used for build or link.
Hello,
I managed to connect the Visual C++ for Linux Development extension. I can upload, compile and run code. The problem is that the code has to print in the console tens and sometimes hundreds of messages per second. The problem is that after a minute or two the console and the entire Visual Studio freezes. Is there a setting that I could make so that I can overpass this problem?
Thank you in advance
Sorry to hear that! Let me see if we can create a repro and get to the bottom of this.
Hi, we fixed this internally, this will be available in the 1.0.6 release of the extension that targets Visual Studio 2015, and RC2 of Visual Studio 2017
Hi, we fixed this internally, this will be available in the 1.0.6 release of the extension that targets Visual Studio 2015, and RC2 of Visual Studio 2017
Hi,
Can you please explain how to lunch an OpenCV desktop application ? I’ve tried the same steps with your OpenGL application but it did not work. Many thanks
Sorry to hear that. I’ll see what I can determine from the samples in the opencv repo.
I’ve been browsing on-line greater than 3 hours today,
yet I never discovered any interesting article like yours.
It is lovely value sufficient for me. Personally, if all website owners and bloggers made just right content as you
probably did, the net will be much more helpful than ever before.
Cool, but currently building is very slow :(. All it takes is to change one source file and all project is copied to remote machine and compiled all over again.
No parallel build, remote copying doesn’t respect my source tree structure (/src/folder1/file.cpp -> /file.cpp) :(
We have fixed those issues in the latest release, can you give it a try? Please let us know if you still have issues with the latest release.
is there support for ARM64 (aarch64) architecture (couldn’t find) ?
do you plan to add such support and when?
thanks
Hi, we do not currently support aarch64, but we do plan on supporting it. Could you tell us a bit about your scenario, and what distro do you use?
Hi Ion – glad to hear that the VS team has plans for supporting aarch64!
While I’m not speaking for hadurz, as an UEFI developer, I for one am very anxious to get aarch64 support, as it would finally complete the ability of using VS as a full fledged UEFI IDE.
Some of the Open Source projects I have been building, and which would benefit greatly from aarch64 support include:
* https://github.com/pbatard/uefi-simple
* https://github.com/pbatard/uefi-ntfs
* https://github.com/pbatard/efifs
* https://github.com/pbatard/EbcDebugger
Does this “Visual C++ for Linux Development” plugin supports cross-compilation?
Hi, not yet, but we have that planned
Great job MS. Is it possible to speed up up copying sources to remote device it seems that even if no sources are changed (just project settings) all sources are copied. On Raspberry Pi it takes forever. Otherwise it seems good
Hi, we have fixed this issue in the latest release, 1.0.5.
Is it possible with this to configure different configurations in the configuration manager and project properties such that I could have a Local Windows debug as one and a remote GDB for another in a single project?
An example of how this would be used is as follows:
1. Develop a QT application within Visual Studio
2. Compile and debug on local windows machine -> “Local Debug Configuration”
3. Deploy, compile, and debug on remote Linux server -> “Remote GDB Configuration”
Hi, no, this is not possible with the way our project system is currently architected. We are thinking of supporting something like it in the future. You could workaround it by having two projects, one targeting Windows, and one targeting Linux, and having the two projects to reference the same sources.
Fascinating tool!! This is exactly what I need for my current dabblings. Question:
Does this Extension support Visual Studio 2013? I have 2015 on my laptop but would like to also use 2013 on my desktop if possible (not looking to update there just yet, nice to have both versions installed for testing/comparisons). Thanks!
No, sorry, we are only targeting Dev14 as an extension, and this will be built into Dev15 directly not as an extension :)
All in all I like the extension.
Two issues I am currently struggling with:
* There is no “Remote Pre-Build Event”. I need other programs modifying my code (like e.g. flex) before compilation.
* If I have an include directory within my project directory and specify “Additional Include Directories” within Project Properties using the macro $(RemoteProjectDir) the tilde character is not expanded. Thus the build fails because it does not find the header files needed.
* Macros like $(RemoteProjectDir) do not have the trailing slash, unlike $(ProjectDir)
Regarding 1), we added a “Remote Pre-Build Event” in 1.0.5. Regarding 2) and 3), we are planning to fix in the next release
Hi,
How can we add additional libraries like in linux with -L flag. I am building opencv project and it failed probably because i am not adding the libraries. For example in ubuntu i have:
g++ -o main_test main.cpp -L/opt/opencv/release/lib/ -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_imgcodecs -lopencv_ml -lopencv_videoio
How can i make the same in VS.
BR
It’s in the properties under Linker>General>Additional Library Directories
What about working with existing projects? lets say i have a makefile, or cmake project, can i use it with Visual Studio now?
We added support for this scenario in in 1.0.5, so this will work. You have to tell the Makefile project what to run, and it will, you will also get IntelliSense support and debugging. If you need more information, please send us an email or reply here.
Could you give some more details of how to use it with existing project? We utilize CMake. I understand that I have to generate makefile, but what to do with it further? How to open it in Visual?
Looks like position-independent executables (-pie) are not supported. When trying to debug a binary linked with -pie, the following message box appears:
Warning:
Cannot insert breakpoint -1.
Cannot access memory at address 0x780
Hi, do you know if you have to set the debugger in a particular way to support -pie debugging? If that is the case, in 1.0.5 we added support for configuring the debugger, if you go to Property Pages – Debugging – Additional Debugger Commands. I will investigate.
While these are great steps that are being taken, please, please, please…. for those like myself who prefer C# or maybe just find C# easier to work with and understand – this one’s definitely me!!- port these same set of tools over to C#, and give a blog post for it, just like you did for C++ here.
tnx so so much very very good website
With the release on Windows 10 “Anniversary Update” that includes Ubuntu could make sense to add the possibility to Visual C++ to have this particular version of Ubuntu as target?
Hi, this is actually possible, our extension works well with the Linux Subsystem for Windows.
Are there instructions somewhere that detail how to set this up?
https://github.com/Microsoft/VSLinux/issues/42#issuecomment-247465406
>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Application Type\Linux\1.0\Linux.Common.targets(188,5): error : unrecognized command line option “-std=c++11”
Seems like your compiler does not support C++11, what you can do to disable targetting C++11, go to Property Pages – C/C++ – Language – C++ Language Standard, and change it to Default.
Such a great article! Thank you very much.
How do I use a Makefile project?
I added a very simple Makefile via an “Existing Item” and changed my build command to `make all` or `make`
Makefile
“`
CXXFLAGS += -std=c++11 -g
all: main.o
main.o : main.cpp
“`
main.cpp
“`
#include
#include
int main()
{
std::array arr = { 2, 3, 5 };
std::cout < Copying sources remotely
1> Invoking make all
1> make: *** No rule to make target ‘all’. Stop.
1>
I wanted to peek at which files VS actually copied, so I changed my build command to `ls -ltrs`, but I can’t even see my main.cpp in a remote project dir.
Ofc it works if I do `make` on a target machine
PLZZZ HALPPPP!!! :-P
How are you creating your Makefile project, are you using the New Project Dialog and choosing the Makefile Project (Linux)? If so, you will need to set your working directory to the directory containing your make script. To do so, in Property Pages, go to Remote Build, Build Command Line, and instead of saying “make all”, say “cd dir; make all”, where “dir” is the remote full path to the directory containing your make script.
The Masamune sword used by the cool devilish Sephiroth is
super long and sharp.
Is it support the openmp? I cannot find the openmp option on the properties.
No, but you can specify openmp options directly on the command line under Property Pages – C/C++ – Command Line
I like this feature, as I can use VS to write and deploy C++ Linux program.
However, when I try to connect my Linux VM before the debug, it is blocked without any response to the input, so I can do nothing except shutting down the whole VS in task mgr.
Does this feature not support VMware?
Roy, sorry to hear that. Our Connection Manager attempts to establish a connection and is setup to wait for up to 30 seconds. If the 30 seconds timeout expires, we show an error. Can you see if that is the case in your scenario, if you wait a little bit more what happens, do you get any red highlights in the dialog? Or does it never completes even after 30 seconds?
Nice capability addition to VS! And great to see MSFT contributing to the developer community in this way.
Hi – I’m trying to figure out how this works – was under the impression that it was simple.
However, in the first test I run into this, and can’t get around it:
Severity Code Description Project File Line Source Suppression State
Error uname exited with code: 1 doormand C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Application Type\Linux\1.0\Linux.Common.targets 51 Build
With reference to this int hte Linux.Common.tagets:
Can’t get around this! Anyone know a reason?
Thank you for this excellent tool, i can’t emphasize enough how great it is :) Is CMake integration next on the list ? That would be awesome !
How do I get GDB to execute the application with sudo as my application needs root access.
Otherwise the GDB support is awesome.
Yes I would also like to know how to debug some stuff that need ‘sudo’ access…. is there a kosher way to do this? For now I seemed to be able to do it by setuid on gdb and gdbserver…
$ sudo chmod ugo+s /usr/bin/gdb
$ sudo chmod ugo+s /usr/bin/gdbserver
Please know that this is NOT SAFE thing to do and you should do at your own risk. But since my linux VM is local on my dev box, I’m okay with it. BTW linux support in VC++ rocks!
How do I reference the libraries in the Raspberry Pi usr/include folder within Visual Studio?
I tried copying this folder to my Visual Studio Environment and adding it to the Project Using Project Properties-> VC++ Directories ->Include Directories but the paths did not flow through as expected when building.
I can’t seem to find the option to add a new .cpp file or .h file from the project window.
I.E Right Click on Project-> Add -> New Item -> Visual C++.
I can only see UnitTest1
And Under Utility RuleSet
I know I can manually drag a cpp file to the project but this feature seems missing.
Thanks for the great job!
I’m going to write a program which need a .so file generated by my co-worker. I add a line like “$(ProjectDir)lib\libRasterizer.so:=$(RemoteProjectDir)/lib/libRasterizer.so” to “Additional sources to copy”. Unfortunately libRasterizer.so was copied to /home/ubuntu/~/projects/ProjectName/lib/ insteadof /home/ubuntu/projects/ProjectName/lib/. So I may need some help to know whether I do it the right way or it’s a bug te be fixed, Thank you!
I tried it with a simple Hello World command-line app and it was ridiculously easy!
What I would really like to do is now compile an existing VC++ project. Is there an easy way to define a new build configuration that I can add to my existing project so that I can easily switch between a local Windows build and a remote Linux build?
Hi. Anyone knows how to force visual to copy files remotely when they get changed?
I have many .lua files as part of my project and any change made to them won’t force rebuild, so I need to change any cpp file to update lua files as well.
Excellent job! Can I add linker option like -lpthread?
I have solved this problem.
how to solve your problem?
I can’t build ‘pthread’
“undefined reference to ‘pthread_create’ ‘pthread_detach’ blabla
help plz.. :(
I am sorry to see this until now. I just add pthread in Linker->Input->Library Dependecies and it works. I hope this can help you.
How about when I want to run openCV library in Linux with Visual Studio. Can you give me a guide for it? Thanks
Hi. I am also very interested in a tutorial for OpenCV.
I can build OpenCV projects on my Linux machine but can’t get it to work from VS on windows (my configuration is probably wrong).
My linux setup:
pkg-config –cflags opencv -> -I/usr/local/include/opencv -I/usr/local/include
pkg-config –libs opencv -> -L/usr/local/lib -lopencv_world
(Intellisense is working when I copy the includes to the Windows machine.)
Thanks in advance ;)
What can be causing a message: “Could not launch gdbserver, unexpected results”? I get it on 2 different PCs with MSVS 14, trying to connect to real Ubuntu 14.04.5 PC and to Hyper-V VM with Linux mint. Everything was fine with Ubuntu PC but it started showing that message instead of running at some point.
I’m trying to add a Pre-Build Event to fetch info from version control system.
Is the pre-build event command executed on the Visual Studio machine or on the remote Linux machine?
Hi I am so excited I found your web site, I really found you by accident,
while I was browsing on Bing for something else, Regardless I
am here now and would just like to say thanks for a remarkable post and a all round thrilling blog (I also love the theme/design),
I don’t have time to read it all at the moment but I have
saved it and also added your RSS feeds, so when I have time I will be back to read a great deal
more, Please do keep up the great jo.
It’s so convenient for everyone who want to use vs to debug linux!
But ~ :
Windows:
Windows 10,
Visual Studio 2015
Visual C++ for Linux 1.05
CentOS:
CentOS 7
g++ 4.8.2
If there are something wrong , the output window just display:
” error : g++ exited with code 1, please see the Output Window – Build output for more details (NOTE: the build output verbosity might need to be changed in Tools Options to see more information in the Output Window)”
It is so wired, that I have updated to 1.05 which is thought to solve this bug.
And my friend told me CentOS 6.5 will be alright.
And there is another problem which is copy so file to remote, although I have set the “Copy remotely” to “yes” , it does NOT WORK …..
for now I must change the “Item Type” from “Library” to “Sources” , and the so file will be copied to remote.
What’s wrong with me TvT
I’ve waiting 1.05 for several months, and nothing improved……
Following these instructions:
”
Verbose build output
We’ve gotten a lot of questions about what exactly are the arguments being passed to GCC. Our build output doesn’t make this obvious, but you can enable it. There are two ways to get to the same place to change this setting. In the quick input window search for “verbosity”, or under Tools, Options go to Projects and Solutions, Build and Run. Now for the option of MSBuild Project output verbosity change it to diagnostic to see everything in your output window when you build. This can really help you find what exactly was passed to GCC to build your program if you are having issues.
”
I can get error from a soup of char…………..
But it is not an elegant way to solve this bug.
It works. But when I use the system headers, you get an error “cannot open source file “.
For example, for:
#include
#include
#include
How to fix it?
sys/stat.h
sys/file.h
unistd.h
From what’s you describing,
I think it’s none of this component’s business .
I can not specify the linux include directories?
Hi, I want to SPECIFY that if you want to build a .so (Shared Object) , you SHOULD add -fPIC at
“Project Properties” –> “Configuration Properties” –> “C/C++” –> “Command Line”.
Otherwise you’ll get an error like
“relocation R_X86_64_32 against `.rodata.str1.1′ can not be used when making a shared object; recompile with -fPIC”;
I’m curious why this useful component does not ADD this parameter automatically?
Hi,
Thanks a lot for this extension, I believe it is going to be fantastic.
Following the console application example, I had two issues.
The first is minor for now as I had to change the debugging mode to gdb to see a breakpoint being hit in a “hello world” example.
Otherwise I get “unable to start debugging register badly formatted” errors, even though both architectures are x64 -a physical machine & a Kubuntu x64 VM-.
After that I tried the sample code provided to get user input and unfortunately it failed with a “Stopped (tty input)” message on the Linux Console.
It all goes well until the scanf line and stepping over it produces the following output:
Program received signal SIGTTIN, Stopped (tty input).
0x00007ffff7b08c70 in __read_nocancel () at ../sysdeps/unix/syscall-template.S:84
-stack-list-frames 0 1000
-var-delete var9
-var-delete var10
-var-delete var11
Stopped (tty input)
-stack-list-arguments 2 0 5
-stack-select-frame 5
-var-create – * “input”
-var-create – * “printf”
-var-create – * “scanf”
-var-create – * “this”
Thanks for your help
Works great, except for the “Additional sources to copy” in the Configuration Properties page.
I have put a source and destination directory in the field like this:
C:\Users\Administrator\Documents\Visual Studio 2015\Projects\ConsoleApplicationUsingTypes\ConsoleApplicationUsingTypes\dependencies:=/home/onefx/projects/ConsoleApplicationUsingTypes/dependencies
Nothing is copied. In the detailed log i see this:
AdditionalSourcesToCopyMapping = C:\Users\Administrator\Documents\Visual Studio 2015\Projects\ConsoleApplicationUsingTypes\ConsoleApplicationUsingTypes\dependencies:=/home/onefx/projects/ConsoleApplicationUsingTypes/dependencies;image.png:=image.png;C:\Users\Administrator\Documents\Visual Studio 2015\Projects\TestCopyfolder:=/home/onefx/projects/ConsoleApplicationUsingTypes/TestCopyfolder
1> AfterBuildCompileTargets =
1> ;
1> AfterBuildCompileEvent;
1>
1> AfterBuildGenerateSourcesTargets =
1>
1> ;
1> AfterBuildGenerateSources;
1> ;
1> AfterBuildGenerateSourcesEvent;
Has anyone sucessfully used this feature?
This plugin is great. Just thinking whether it is possible to somehow incorporate the unittest framework into this as well?
What about VisualGDB?
e.g. http://visualgdb.com/toolchains/embedded
Prefer to compile/build on my Windows 10 machine and then deploy to the target (embedded Linux) device.
There are a lot of cross platform Windows/Linux projects. With this move toward Linux development we have huge opportunity to do development of these project in VS. So I have question:
Is it possible to configure projects (and solutions) to target both Linux and Windows?
Do you have example?
How can i change the “Remote Setting/Target Machine” on a msbuild, in the command line, for a Visual Studio with Visual C++ for Linux Development. I need to change the Target Machine property. For visual studio in the project properties / Configuration Properties/ Remote Setting / Target Machine, I have “pc9602 (username=me, port=22, authentication=Password)
I want to change it in the command line for our build machine. What shoud I add to the command line below ?
msbuild /p:Configuration=Debug /p:plarform=x64 myapp.sln
And if I change the authentication the ssh, how would I pass it to the command line ?
Thanks.
Hello, I think your blog might be having browser compatibility issues.
When I look at your blog site in Opera, it looks fine but when opening in Internet Explorer, it has some
overlapping. I just wanted to give you a quick heads up!
Other then that, awesome blog!
Is there simple way to copy all the CMakeLists.txt files to remote directory? It seems I have to manually specify the current location and remote location for each CMakeListsd.txt file.
Can you attach and debug to a process already running ?
This is Great!, I was able to build my Linux target. Next thing I would like to do build the same target in Windows. To do this, I will have to create one more project file with same source code, which is costly.
My question is can I build both Windows and Linux with a single project file. With one platform configuration[Linux] it can connect to remote machine and build Linux Target and in another platform configuration[Windows] it can build locally or even connect remote windows machine and build the target will also suffice!
Hope my question is clear! thanks
just upgraded to sp3( as required by the latest version) – wonderful, first thing I got ” you can add a machine using Linux Connection Manager” . I searched MSFN, I googled – nothing . Where is the freaking “Linux Connection Manager”? Did they forget to ship it ?
Tools > Options > Cross Platform > Linux.
Dear All,
Is it possible to use the Bash on Ubuntu on Windows environment as the Linux system needed for building, debugging, etc.? If yes, what are the specific configuration steps (eg. when connecting)?
Thanks,
T
Yes – you can use WSL.
I haven’t done it but the instructions are here on the GITHUB support pages
https://github.com/Microsoft/VSLinux/issues/42
I’m just starting to use this for my team’s development and it looks like it’s going to make a big improvement to how we work, so thank you. I do have a couple of questions I hope you can help me with:
1) Within the project properties I have to precede all my remote build commands with a cd to the project directory. Shouldn’t the build happen in the ‘Remote Build Project Directory’ by default?
2) I also have to include a command to load my bash profile in the remote build commands otherwise my path appears not to be set. Shouldn’t the connection to the Linux server load my profile automatically?
I notice that 1.06 has been released. Think you guys could post here and updates/changes/fixes with this version ?
It’s awesome, unbelievable, excellent feature for VS. I can’t hide my excitement here and I can’t wait to finish downloading it….
Nice introduction to Linux dev!
Does someone have some hints for how to combine two different projects?
– The blinking example is straightforward to compile and run on my Raspberry Pi 3.
– And now I would like to compile another program (XsensDeviceAPI MTix and MTmk4 Src Example) on my Raspberry Pi via Cross Debuggin of Visual Studio 2015. This program uses a lot of header files/source files and so on…
Do I have to create a new project or is it possible to take e.g. the blink example and add the properties (header files/source files/…) manually or can that be done automatically? I would be grateful for some help :)
Hello! Is there a way to display “Connect to Linux dialog” and change password?
I’m try to change address and password and there is a problem in project-settings-general tab.
yes
Tools > Options > Cross Platform > Linux.
Hi,
This feature of Visual Studio is really fascinating. I’ve built the “Makefile Porject” successfully on a single Linux VM. But now I have a Windows PC, a Linux VM and an ARM device. The cross compiler is on Linux VM and the output binary will run on ARM. I’ve already build an ARM version gdbserver, how to configure visual studio to build on Linux VM and debug on ARM?
Thanks.
BR,
Tiandong
1. when I create a makefile vsproj on windows to compile the remote project linux-based, I cannot debug it by vs2015 Debug->Start Debugging patton. and when I click it, a dailog appears “Failure”, something like “Cannot copy file ‘xxx’, file not found on the remote system.”, xxx here is the configure value Remote build->Outputs. ( it only can compile it now)
2. can you tell me how to solve it? thank you~
Awesome plug-in. 5 stars even there’s bugs.
For the newest version, I tried it and found a bug.
I cannot set breakpoint once program is running. It only works when I set breakpoints before I start debugging. Have you triggered this situation?
Best regards
I find the problem that I use wifi to connect my raspberry pi. and the wifi of raspberry pi is not stable so it leads to this problem. I use another wifi adapter on raspberry pi and its works good now.
Our small org uses C# on the front end and Linux on the back end. As the C# guy, I’ve found a need to do some back end C++ coding, and this is helping me get going. I have Centos running in Oracle Virtual Box for now for testing.
One thing I’d like is perhaps a project template that would allow me to build and debug locally as well as to build and debug remotely. The project would need extra configurations added as well as extra pre-processor definitions as some code would perhaps be windows or Linux specific or might need different paths set up for linking to the appropriate libraries.
It seems that Additional options in Command Line options are not work (both in compiler and in linker). I used “Configuration Properties->Linker->General->Linker” field to add -pthread option like this “g++ -pthread”.
And when I use “Configuration Properties->CopySources->AdditionalSourcesToCopy” I can’t find any way to copy some files to output directory. All remote directory macroses starts from “~” symbol. And after copy directory with name “~” will be created. I don’t know why “~” is not used like a root :( So it is possible to use only absolute paths?
http://bnp21.com/board_iOAP23/89709
Greetings,
I have a problem with keyboard entries to the Linux Console Window. They are read several times.
If I run this Code:
#include
#include
using namespace std;
int main()
{
cout << "Push any Key." << endl;
cin.clear();
char c = getchar();
for (int i = 0; i < 10000000; i++) { i / 3; }
cout << "output: " << c << endl;
for (int i = 0; i < 10000000; i++) { i * 3; }
return 0;
}
And I push: "1" + Enter. I am getting as output to Linux Console Window.:
Push any Key:
1
1
1
1
1
1
1
1
1
1
output: 1
If you make the first for loop run shorter, it results in the "output: 1" move up between the ones.
As the target machine I am using a RaspberrPi. Am I doing something wrong?
excellent work…
I have Embedded linux board with 7″ touch display.
Can i develop GUI Application in visual studio?
Can I use this to play games that require it?
Great job!!!
Is there any way that I can use CMAKE to generate such project for cross build and debug?
Assume that I have a cmake and I can create VS projects with it, can I use the cmake to generate cross platform projects in visual studio? If yes, do you have any sample?
—————————
Microsoft Visual Studio
—————————
Could not launch gdbserver. gdbserver could either be missing on your system and needs to be installed, or it failed to start the program.
—————————
确定
—————————
我提示这个错误,是不是因为linux上没用安装gdbsever,那么应该如何安装并使用呢?求帮助。。。。。
Nice to see the update here re Linux development on VS2017.
Unfortunately, installing VS 2017 cause a ton of problems on my main desktop PC.
I’ve had to re-install Windows 10 (and everything else I need).
It will be a while before I try installing VS 2017 again.
Look forward to updates from you folks here.
Looks marvelous if i could get it to work it would be even better.
My connection manager connects OK.
I can use ssh and sftp fine.
In the Tools->Options->Cross Platform i have added the connection and verified it connects.
But i get the error
“`
error : Could not connect to the remote system. Please verify your connection settings, and that your machine is on the network and reachable.
“`
so really a bit show stopper.
Any advice?
Hi,
i try create Linux project on PINE64 board with Ubuntu Xenial 4.1
Connection manager say Ubuntu (Unknown) and VS 2017 can’t build project remotely.
uname -m
say aarch64.
How to resolve this issue ?
Is it possible to generate a Linux c++ visual studio project from CMake. I have a CMake / c++ project which works on Linux when compiled on it but i would like to be able to debug / edit code from visual studio
I’m using the BeagleBone Black with debian and when I want to start debugging an error message comes up, “error building. want to continue and run the last succesfull buil?” after hitting yes this message comes up: “Unable to start debugging. Unexpected GDB output from command ‘-interpreter-exec console ‘target remote localhost:50995”. Remote connection closed”
The error description is: “unrecognized command line option ‘-std=c++11
The project nevertheless is on the BBB but not the /bash/debugging/ directory so I can’t run it
Thanks for your help
It’s a shame you don’t have a donate button! I’d without a doubt
donate to this superb blog! I suppose for now i’ll settle for bookmarking and adding your RSS feed to my Google account.
I look forward to brand new updates and will share this site with my Facebook group.
Talk soon!
Very good!
I just set up my current project to test it out (I would really like to not need a VM, so I did install Ubuntu on Windows as well).
Is there a way to set a project to have two different targets, one for Windows and another one for Linux?
Seems like target device is disabled for my project and I cant create another set of targets.
I have several makefile build projects on Linux. The projects use several third party libraries for compilation and linking. These are installed under /usr/local/*, /opt/*, /u01/oracle/* etc. My project source root is mapped as a sub-directory in my home directory (/usr/users/tofu/project/src/*).
a. How does VS IDE resolve symbols in code editor for these 3rd party headers? Does it have access to the 3rd party include files distributed all over my Linux machine? Eclipse CDT requires me to add all these directories in the build path for its code indexer to resolve symbols.
b. Eclipse CDT on Linux has a hard time resolving embedded sql for Oracle pro*C code. Will the VS IDE be able to resolve these?
c. External make copies executables to a different directory using different names. Is there any additional configuration needed in VS while pointing to an external make project? Are there any limitations I should be aware of?
d. I need to have a bunch of env vars set before compilation, linking and execution on the Linux machine. Is there a provision for this in VS?
Very great! But I met one problem need your help.
1) I have one linux-based proj on remote linux board.
2) on windows, I create a linux Makefile project(empty), and download the remote project sources files, adding to vs2015proj.
3) I set the “Remote Build” page configure, and now I can compile it.
But, problem is I cannot debug or run it by vs2015 ide. maybe some settings missed, can you help me?
(when I launch debug by vs2015ide, there will be an err dailog at the last, showing “Cannot copy file ‘xxx’, file not found on the remote system.”, xxx is the “Remote Build->Outpus” values)
I was rather excited to try this, but unfortunately, I also get the “Could not select a local port for communication with gdbserver” error when trying to run a program and could not proceed further… :-(
Any fixes for this yet?
Hi Guys,
Great work. However, I have a lot of challenges compiling and editing a project. We go one by one. My project is a large c++ project with files extension .C visual studio doesn’t treat it as c++ even though I defined the extension via Tools>options..>..Editor>Exte..
It complains that identifier “namespace” is undefined and this is why I am thinking VS still not recognizing the files as c++ after all.
I will apreciate the help.
Br,
Moe
Hello,
i use the VCLinux with VS 2015 and a Raspberry PI with debian jessy.
On This Example i use the Linux-Console Application
The compile goes. Debugging goes also to the first function, after this comes always the following error:
————————————————–
Program received signal SIGSEGV, Segmentation fault.
0x00000000 in ?? ()
Segmentation fault
Program terminated with signal SIGSEGV, Segmentation fault.
….
——————————————————
What is the problem?
@MarioR,
I was having same exact issue.
1) Right-click your project and select Properties > Configuration Properties > Debugging
2) Change ‘Debugging Mode’ from ‘gdbserver’ to ‘gdb’
3) Try to debug again.
Cheers,
Leo
how to attach to the remote linux application and debug it?
Seems like the Microsoft guys aren’t monitoring this blog any more so I’ll try to help.
I assume you have set up a connection to your Linux system and were able to compile the code.
In VS go to the Debug dropdown and click on Linux Console.
A Console window will popup that will display the Debug results
I’m having trouble with Debug after the latest update – keep getting memory error
Anyway hope this helps
Maybe you have some memory leaks in your program,VS2017 is just a remote compile and debug tool. In substance ,there is no relationship with Windows ,all work is done by the linux virtual machine.
The problem was an update to gdbserver
Issue is described here – no solution
https://github.com/Microsoft/VSLinux/issues/119
Are there any plans in the roadmap to allow local cross compiling?
For example, like in VisualGDB? Seems like it would be very easy to have the current remote Linux and WSL support have an option to just run the cross compilers locally and use the same solution space rather than remoting.
It is possible use the Linux console as ANSI Terminal (for colored text)?
I have the same question with you,Now I solved lots problems about how to use vs2017 for linux develop,if Linux console window can be used as terminal,that will be very great!Is there anyboby soleved this problem?
I have not solution. It is possible to use an external (no-Microsoft) console with ANSI support?
Is it necessary to copy built binary back to the host? Some target binaries might has huge size which makes remote debugging really time-expensive. Is there any possibly to fix or WA this issue?
When I add my remote Linux machine the entry in the “OS” column of the Connection Manager is “Ubuntu (Unknown)”, versus “Ubuntu (x64)” for a second machine I added as a test.
When I try to compile a test project on my target machine (the one with the “Unknown” architecture) I get a compiler error saying “Current project architecture ‘x64’ is incompatible with the remote system architecture ” (‘Unknown’). Please switch the project architecture to ” in Configuration Manager.”
I know for a fact my target machine has an x64 architecture.
Does anyone know how to address this?
Is it possible to build in an x64 Linux machine, but deploy/debug on an ARM device?
Currently, I have all the toolchain to build on ARM. VS2017 Cross-Platform allows me to transfer-and-build on the Linux machine, but seems like debugging has to happen on the same machine too. I can only find “Remote Build” parameters, but not “Remote Target” parameters.
Am I missing something?
I’m using vs2017 for cross platform development, but I got an error while gcc4.9 compiling Andorid project, file “xmmintrin.h” , here is the error report:
D:\Program Files\vs2017\Common7\IDE\VC\Linux\include\usr\lib\gcc\x86_64-linux-gnu\5\include/mmintrin.h: In function ‘void _mm_empty()’:
1>D:\Program Files\vs2017\Common7\IDE\VC\Linux\include\usr\lib\gcc\x86_64-linux-gnu\5\include/mmintrin.h(51,24): error : ‘__builtin_ia32_emms’ was not declared in this scope
1> __builtin_ia32_emms ();
1> ^
1>D:\Program Files\vs2017\Common7\IDE\VC\Linux\include\usr\lib\gcc\x86_64-linux-gnu\5\include/mmintrin.h: In function ‘__m64 _mm_cvtsi32_si64(int)’:
1>D:\Program Files\vs2017\Common7\IDE\VC\Linux\include\usr\lib\gcc\x86_64-linux-gnu\5\include/mmintrin.h(64,54): error : ‘__builtin_ia32_vec_init_v2si’ was not declared in this scope
1> return (__m64) __builtin_ia32_vec_init_v2si (__i, 0);
1> ^
1>D:\Program Files\vs2017\Common7\IDE\VC\Linux\include\usr\lib\gcc\x86_64-linux-gnu\5\include/mmintrin.h: In function ‘int _mm_cvtsi64_si32(__m64)’:
1>D:\Program Files\vs2017\Common7\IDE\VC\Linux\include\usr\lib\gcc\x86_64-linux-gnu\5\include/mmintrin.h(107,53): error : ‘__builtin_ia32_vec_ext_v2si’ was not declared in this scope
1> return __builtin_ia32_vec_ext_v2si ((__v2si)__i, 0);
1> ^
1>D:\Program Files\vs2017\Common7\IDE\VC\Linux\include\usr\lib\gcc\x86_64-linux-gnu\5\include/mmintrin.h: In function ‘__m64 _mm_packs_pi16(__m64, __m64)’:
1>D:\Program Files\vs2017\Common7\IDE\VC\Linux\include\usr\lib\gcc\x86_64-linux-gnu\5\include/mmintrin.h(146,69): error : ‘__builtin_ia32_packsswb’ was not declared in this scope
1> return (__m64) __builtin_ia32_packsswb ((__v4hi)__m1, (__v4hi)__m2);
1> ^
thousands errors like this
I have try some ways such as -mmmx -msse2, but it does not work at all.
How could I solve this problem?
Waiting for your answer and thanks a lot .
Would I be able to perform Linux Kernel Development as well?
I have the same question.
I’ve built the Linux kernel before with this before. I’ll give that a spin with our new open folder support as that shouldn’t even require converting anything. Might make a good blog post. Note that I don’t think we’d be able to do kernel mode debugging.
I got an issue:
If add an breakpoint in the shared object’s function, then call this function in main, VS2017 would not hit this breakpoint.
Is there solution to resolve it?
By default we use gdbserver and our own gdb client from VS. It sounds like that isn’t compatible with what you have. In project properties go to the debugging tab and change the debugging mode to gdb. That will use the gdb client on your linux box which should work.