zoukankan      html  css  js  c++  java
  • visual studio 开发linux程序

    VisualGDB支持Linux的原理是,通过ssh连接到Linux系统上通过ssh给linux下达命令 . (类似visualgdb的有windgb  ,这2个都是商业软件。)

         Visual GDB把GDB调试工具集成到visual studio 开发环境中,在调试过程中,可以使用visual studio原有的单步执行、设定断定等快捷键,还可以在visual GDB session的窗口中输入GDB的调试命令,集成了visualGDB之后还可以在程序执行的过程中用鼠标悬停的方式查看和修改变量的值,这样在不改变调试习惯的同时还可以使用GDB强大的调试功能,很不错。

    http://visualgdb.com/documentation/linux

    官方的linux工具:

    Visual C++ for Linux Development 

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

    https://visualstudiogallery.msdn.microsoft.com/725025cf-7067-45c2-8d01-1e0fd359ae6e

    目标机要安装gdb+gdbserver

     

     visualgdb教程:http://visualgdb.com/tutorials/linux/
     
    我新建一个工程使用:
     
     
    从上面可以看到就是把windows上面的文件通过scp copy到远程主机上。
    As the same source code will be edited under Windows and then compiled under Linux, VisualGDB will need to keep the sources synchronized. The easiest way is to use automatic file uploading via SSH. Alternatively, VisualGDB can setup shared folders (that would require root password).
     
    他是怎么实现提示提示的,可以看到是通过下载linux下面的头文件来实现的。会把linux下面的.h文件缓存到windows上面。
    Press Finish to complete the wizard. If you are setting up your first project using this Linux machine, VisualGDB will make local caches of the include directories to make them available through IntelliSens 。
     
     
     
     
    http://www.cnblogs.com/hbccdf/p/use_vs_and_visualgdb_develope_linux_app.html
     
     
     

    使用Visual Studio 2017作为Linux C++开发工具

      https://www.cnblogs.com/dongc/p/6599461.html

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

    https://www.bilibili.com/video/av7718718/

    ubuntu服务端安装软件:

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

    在第一次build之前会要求ssh连接到目标linux机器,填上用户名密码连接目标机器。如果需要更换目标机器地址,在Tools/Options/Cross Platform下进行管理。

    设置好一系列选项(黑体部分),与普通的Win32程序的设置基本一致。需要注意如下2点:

    • vs不会自动把addtional include中的头文件复制到本地来做代码补全的提示,需要手动将linux下面的/usr/include目录复制到vs的linux header path(如:C:Program Files (x86)Microsoft Visual Studio2017CommunityCommon7IDEVCLinuxincludeusr)
    • 注意,这一步一定要复制对,否则还会有找不到头文件,没有代码提示等问题,是将linux下  /usr/include目录整个复制到 ***IDEVCLinuxincludeusr下,如果还需要复制其他头文件(/usr/local/include),照这个规则复制就可以,其实记住一点就可以:***IDEVCLinuxincludeusr这个目录就相当于linux下/usr 目录

    vs2017默认的如上面,

    我把ubuntu下面的/usr/ include include文件夹压缩,然后把include里面的内容复制到上图的include里面去 。一些unistd.h就可以找到了。

     (

    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.

    )

    • 提示,linux下使用gcc编译的时候,加上-v参数,可以显示所有搜索头文件的路径,保证目录结构copy过来就可以

     vs还带有自动copy linux头文件到本地的功能:

    菜单栏-》工具-》选项:

    点更新会自动把linux下面的头文件同步到windows上面来。下载下来的linux头文件路径在:C:UsersssAppDataLocalMicrosoftLinuxHeaderCache

     (微软的软件一直很强大,很多都给你想好了)

    https://www.zhihu.com/question/26388094

    语法高亮,代码补全

    vs自身只带了少部分的Linux头文件,如果要用到其他头文件或者第三方库,可以将头文件拷贝到本地目录,然后将目录添加到项目的include目录中。

     

    编译时vs会将代码复制到目标机器的~/projects/[project-name]目录下,二进制文件在其目录的bin目录下。如下图,Linux环境下可以看到,已经有代码了。

    打开 调试 -> ConsoleApplacation1属性页 就可以看到Visual C++ for Linux Development的各项配置。

     

     

    1. 比如在我的服务器上,调试模式生成的可执行文件的目录是在~/projects/ConsoleApplication1/bin/x64/Debug

    2. 如果你有多台服务器的话,可以在 调试-> 选项 -> Cross Platform -> Connection Manager 处添加一台新的远程服务器。

  • 相关阅读:
    java中的定时器
    JAVA中的定时器
    jQuery中的show()和hide()、fadeIn()和fadeOut()、slideDown()和slideUp用法
    ArrayList和LinkedList区别以及list,set,map三者的区别
    java.util包常用的类和接口
    字节流 字符流 输入流 输出流
    运行时异常和checked异常异同
    exception和error异同
    MVC控制器传递多个实体类集合到视图的方案总结
    利用Asp.net和Sql Server实现留言板功能
  • 原文地址:https://www.cnblogs.com/youxin/p/5615934.html
Copyright © 2011-2022 走看看