首页运维零件 › 上编译、甚至还能接上 gdbvns威尼斯城官网登入,目前我们仅支持在远端的目标 Linux 机器提供建构服务

上编译、甚至还能接上 gdbvns威尼斯城官网登入,目前我们仅支持在远端的目标 Linux 机器提供建构服务

现今我们正在开辟贰个新的插件,一个能力所能达到让开采者在 Visual Studio (以下简单的称呼VS 卡塔尔 上建设结构能够在 Linux 上运转 C++ 程序的套件。开荒者能够借由那么些插件将
C++ 程序移转到 Linux 服务器、PC
以至运动道具上,也还要能够借由这么些插件将那几个机器连结至你的 VS 上。

微软明日在官方MSDN博客上发布文书表示他们正在开垦八个新的插件,叁个力所能致让开采者在Visual
Studio上营造能够在Linux上运转C++程序的套件。开辟者能够借由这些插件将C++程序移植到Linux服务器、PC以至运动设备上,也相同的时候能够借由这一个插件将这个设施连接至VS。看见那一个新闻,网上朋友纷繁表示,Visual
Studio果然是大自然第一IDE!

原文  https://blogs.msdn.microsoft.com/vcblog/2016/03/30/visual-c-for-linux-development/

在 Linux 上支付 C/C++ 程序,只怕你会向来(本机或远端)登陆Linux,张开编辑器写完代码后,就用 gcc/g++
来编写翻译,蒙受要除错(debug)的时候,则会采纳选拔 gdb
来进展除错。今后,借让你赶巧也很心爱 Visual
Studio,你能够不用改造习贯,用 Visual
Studio写程式、然后远端送到
Linux 上编写翻译、以致还能够接上 gdb
来除错。这一个对于开垦疑似嵌入式系统、或是 IoT
装置的主次等等就足以多Dolly用 Visual Studio 强盛的 IDE 手艺。

VS
将会活动地复制一份并在远端创立你的来源档,再运转带有除错器的应用程序。大家的那项安顿也针对卓越的架构提供系统帮忙,包含ARM 等。

微软还在博客中详尽介绍了该类型的使用方法,感兴趣可观望如下原文

Visual C++ for Linux Development

Today we’re making a new extension available that enables C++
development in Visual Studio for Linux. With this extension you can
author C++ code for Linux servers, desktops and devices. You can manage
your connections to these machines from within VS. VS will automatically
copy and remote build your sources and can launch your application with
the debugger. Our project system supports targeting specific
architectures, including ARM. Read on for how to get started with our
new Linux projects.

Today we only support building remotely on the Linux target machine. We
are not limited by 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

vns威尼斯城官网登入 1

江湖作品将继续介绍使用我们那套崭新的 Linux 安插。

一时一刻大家仅扶持在远端的目的Linux机器提供创设服务。大家并从未界定特定的Linux发布版本,但我们如故在部分工具的变现上微微相依性的分裂。需求极其注意的是,大家需求openssh-server、g++、gdb以至gdbserver。用你最习于旧贯的套件管理工科具来设置他们,比方在Debian类型的Linux就能够使用:

Installation

Download the Visual C++ for Linux Development
extension or get it from the extension
manager in Visual Studio. Today we do have a dependency on the Android
Tools for Visual Studio. If you already have VS installed you can add
those by going to Add Remove Programs, modify Visual Studio and select
them under Visual C++ Mobile Development.

To get started create a new project by going to Templates > Visual
C++ > Cross Platform > Linux
 .

vns威尼斯城官网登入 2

Today we have three templates available; Blink for IoT devices like the
Raspberry Pi, Console Application as a bare application, and Empty for
you to add sources and configure from a clean slate.

图: 应该有不菲在 Linux 上写程式的开拓人士是这么工作的呢?

脚下我们仅扶植在远端的对象 Linux 机器提供建设布局服务。大家并不曾限定特定的
Linux
发表版本,但大家照样在一些工具的显现上稍稍相依性的差距。须要特别注意的是,大家要求openssh-server、g++、gdb 以及gdbserver。用你最习于旧贯的套件管理工科具来安装他们,比方在 Debian 类型的
Linux 就足以应用:

sudo apt-get install openssh-server g++ gdb gdbserver

Your First VS Linux Project

Let’s get started by creating a Console app. After creating your project
from that template set a break point on the printf statement then hit F5
or the Remote GDB Debugger button. By default, the Console Application
is set to a debug/x64 configuration. If your remote target is x86 or ARM
you’ll want to change those options first. In this example I’m using a
x64 Ubuntu VM.

vns威尼斯城官网登入 3

Since this is our first time targeting a Linux machine you will be
prompted for connection information.  This is triggered by building the
project.

vns威尼斯城官网登入 4

We support both password and certificate base authorization, including
use of passphrases with certificates. Upon a successful connection we
save your connection information for subsequent connections. You can
manage your saved connections underTools > Options > Cross
Platform > Linux
 . Yes, passwords/passphrases are encrypted when
stored. We plan to support connecting without saving the connection
information in a future update.

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.

vns威尼斯城官网登入 5

  如何做?

sudo apt-get install openssh-server g++ gdb gdbserver

安装

Linux Project Properties

Let’s take a look at the project properties to understand where things
got deployed on the remote Linux machine.

vns威尼斯城官网登入 6

Under remote settings, you will see the remote root is set to
~/projects/ by default and that we are setting the remote project
directory to match our project name in that location. If we take a look
on the Linux machine, we’ll find main.cpp as well as our build artifacts
in ~/projects/ConsoleApplication1.

vns威尼斯城官网登入 7

Looking at the General settings for the project, you can see how our
output and intermediate directories were configured. Additionally,
you’ll see that this project was configured as an application – thus our
executable is under bin/x64/Debug/ as ConsoleApplication1.out. Notice
that for configuration types we also support static and dynamic
libraries.

  首先,你不能不运用 Visual Studio 2016,你可以动用无偿版[1]的 Visual
Studio 二〇一五 Community 或是其余更加高阶段的版本,记得在装置时要勾选 Visual
C++ 以及 C++
跨平台行动付出那多少个零件:

安装

下载 Visual C++ for Linux Development
extension 或从 Visual Studio
上的插件管理员来赢得。最近我们在 Visual Studio 上的 Android Tools
杪春有相依扶植。假设你曾经设置了 VS 的话,你能够借由 Add Remove Programs
来新扩充这个成效,编辑 VS 然后在 Visual C++ 移动设备开荒下抉择他们。

要从头三个新的品类方可通过以下渠道:Templates > Visual C++ > CrossPlatform > Linux。

vns威尼斯城官网登入 8

一时一刻大家有八个能够应用的模版:针对像 Raspberry Pi 等物联网装置设计的
Blink、最主题的应用程序样板 Console Application
以致让开拓者自个儿选取需求参与的来源档以至从预设设定起的 Empty。

下载Visual C++ for Linux Development extension或从Visual
Studio上的插件管理员来博取。近期我们在Visual Studio上的Android
Tools央月有相依帮助。借使您早就设置了VS的话,你能够借由Add Remove
Programs来新添那几个意义,编辑VS然后在Visual C++移动器材费用下抉择他们。

Linux IoT Projects

Now let’s take a look at an IoT device, the Raspberry Pi. You can use
any type of Pi running Raspbian. For our blink sample we
use wiringPi – if you don’t have this setup you
can either install it via apt or from source. To add a new connection,
go to Tools > Options and search for Linux. Now click add to
connect to your Raspberry Pi.

vns威尼斯城官网登入 9

Go to project properties and take a look under Build Events at Remote
Post-Build Events.

vns威尼斯城官网登入 10

You can use this to execute a command on the remote Linux target after
build. This template comes preconfigured to export the GPIO pin for the
LED so that we don’t have to run our executable as root.

Now connect an LED to pin 17 on your Raspberry Pi as shown here.

vns威尼斯城官网登入 11

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.

Visit our IoT Development page to stay current on
all of our offerings in this space.

vns威尼斯城官网登入 12

您的首先个 VS Linux 项目

咱俩从创立一个主要调节台 app 带头。从沙盘模拟经营新扩展完你的门类后,在 printf
陈说句的地点设下三个中断点,然后敲击 F5 或远端 GDB
除错器开关。依照预设值,这么些主要调控台 app 设定与 debug/x64
的条件相容。借使您的远端连线标的是 x86 或 arm
结构,这你须要先转移上述设定。在自己现身说法的这一个典范我利用的是 x64 Ubuntu
VM。

vns威尼斯城官网登入 13

是因为这是首先次对接到标的的 Linux
机器,所以会弹出二个连连资源信息视窗,是由在组建项目时所接触的。

vns威尼斯城官网登入 14

大家同期援助密码以至表达情势的辨证措施,包罗使用复杂密码的求证。在第贰回中标连接后,大家会将您的联网资源新闻积存以便在以往亟待连接时快速存取。你能够从
Tools > Options > Cross Platform > Linux
的路线来保管你已囤积的连接资讯,以至科学,密码/复杂密码是已加密方式积累的。大家也同不平日间布置在今后的翻新版本中,在一而再时无需寄存连结资讯。

在一连的进程中,你的源点档会被复制到远端的 Linux 机器上,并触发 gcc
并依据项目标本性设定来创设原始码。在档案的次序构建完成之后,你的次第将会在远端的机器上进行,并结束在大家原先所设下的中断点上。

要起来二个新的门类得以透过以下路子:Templates > Visual C++ > CrossPlatform > Linux。

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: libgles1-mesa, libgles1-mesa-dev, freeglut3, freeglut3-dev.

Now create an empty Linux project and go grab the source for Spinning
Cube fromJulien 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 .  Now go to your project
properties and add export DISPLAY=:0.0 to the Pre-Launch command.

vns威尼斯城官网登入 15

Now, under Linker Input add the library dependencies: m;GL;GLU;glut.

Also, make sure your remote settings are for the right machine.

vns威尼斯城官网登入 16

Now hit F5.

vns威尼斯城官网登入 17

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.

  图: 安装 Visual C++

Linux 项目性质

咱俩能够借由以下的品类性质来通晓,东西是怎么被布置到远端 Linux
机器上的。

vns威尼斯城官网登入 18

在 remote settings 下,你能够看看 remote 根目录是预设在 ~/projects/
,且该路线下的远端项目目录会与大家的项目名称切合。从 Linux
机器上去看的话,大家能够在 ~/projects/ConsoleApplication1
下发掘创建后的出品 main.cpp。

vns威尼斯城官网登入 19

基于项目标 General setting,可以了然到我们本着 Output 以致 Intermediate
路线是怎么设定的。除外,你能够发掘到那么些项目是被设定成三个应用程序的
— 代表大家的品种施行档 ConsoleApplication1.out 是在 bin/x64/Debug/
路线下。其它能够小心到的是,大家也同不常候协理静态以致动态的设定格式。

脚下大家有多少个可以利用的模板:针对像Raspberry
Pi等物联网装置设计的Blink、最宗旨的应用程序样本Console
Application以至让开荒者自个儿选用必要参预的来源档以至从预设设定起的Empty。

Go Write Some Native Linux Code

We hope you are as excited by the possibilities this opens up as we are.

Install the Visual C++ for Linux Development
extension , try it out and let us know what
works for you, what doesn’t or if you encounter any issues. If your
focus is IoT remember to check out our IoT Development
page to stay current on happenings there. You can
reach us here through the blog, on the extension page on the gallery,
via the VS Feedback channel, or find
our team @visualc  or
me,  @robotdad , on Twitter.

– Marc Goodner

  然后如果再安装 Visual Studio GDB Debugger 那么些扩展套件,就可见在
Visual Studio 的 Visual C++ > 跨平台的品种类别中精选 Makefile Project
(GDB卡塔尔国 的花色范本。

转载本站文章请注明出处:vns威尼斯城官网登入 http://www.tiec-ccpittj.com/?p=4864

上一篇:

下一篇:

相关文章