简体   繁体   English

在Windows IDE中编写C ++代码并在Linux终端中进行编译的有效方法?

[英]Efficient method of writing C++ code in Windows IDE and compiling in Linux terminal?

First of all, it's all about maximizing the productivity as a c++ programmer. 首先,这是关于最大程度地提高作为c ++程序员的生产力的方法。 My regular work is to use Windows ssh client such as xshell to log in to remote linux machine via ssh and do many linux work there. 我的常规工作是使用Windows ssh客户端(例如xshell通过ssh登录到远程linux机器,并在那里进行许多linux工作。 Imagine I want to set up a big C++ project, and now I'm faced with a trouble. 想象一下,我想建立一个大型的C ++项目,但是现在我遇到了麻烦。

  • If I write code in Windows IDE, I need to propagate the changes every time I modify some files to linux machine, and compile there. 如果我在Windows IDE中编写代码,则每次将某些文件修改到linux计算机并在那里编译时,都需要传播更改。 (Consider compiling in Windows is not feasible or very slow) (考虑在Windows中编译不可行或速度很慢)
  • If I write code in linux terminal, as it's gonna be a big project(not just a simple hellowrold), the productivity in working on vim or emacs cannot match with that in Windows IDE. 如果我在Linux终端中编写代码,因为这将是一个很大的项目(而不仅仅是一个简单的hellowrold),那么在vim或emacs上工作的生产力就无法与Windows IDE中的生产力相提并论。

Here I want to exclude some options such as samba , configuring many plugins for vim, or just buy a Mac. 在这里,我想排除一些选项,例如samba ,为vim配置许多插件,或仅购买Mac。 And if I write in Windows, it's undesirable to copy the whole contents to remote machine every time syncing with it. 而且,如果我使用Windows编写,则每次同步时都将全部内容复制到远程计算机是不可取的。

Any ways or tools to make this process easier and productive ? 有什么方法或工具可以使此过程更轻松,更高效?

Here are some options: 以下是一些选项:

  • Option 1: Use mobaxterm (which is a very fast xserver on windows) to run your IDE. 选项1:使用mobaxterm (在Windows上是非常快的xserver)来运行IDE。 I run Qt Creator over the internet and it's instantaneous, so no lags. 我通过互联网运行Qt Creator,它是瞬时的,所以没有延迟。
  • Option 2: Use VNC only for that program. 选项2:仅将VNC用于该程序。 So create some VNC server and run your IDE in it. 因此,创建一些VNC服务器并在其中运行您的IDE。 This doesn't work for me because the VNC server (realvnc I think) crashes all the time. 这对我不起作用,因为VNC服务器(我认为是re​​alvnc)一直崩溃。 Maybe you'll be lucky. 也许你会很幸运。
  • Option 3: Use VNC with desktop environment. 选项3:在桌面环境中使用VNC。 I got this to work at work, but not at home. 我让它上班,但不在家。 It depends on what desktop environment you want to use, something like icewm is fine (the command on linux is vncserver for that). 这取决于您要使用的桌面环境,诸如icewm之类的东西就可以了(Linux上的命令是vncserver )。
  • Option 4: Use X2Go as your remote environment. 选项4:使用X2Go作为您的远程环境。 Install the server on your linux, and connect to it with ssh. 在Linux上安装服务器,并使用ssh连接到它。
  • Option 5: Use xrdp protocol. 选项5:使用xrdp协议。 Install it on linux, and use windows remote desktop to connect to your linux machine from windows. 在Linux上安装它,并使用Windows远程桌面从Windows连接到Linux机器。

Warning: If you're using VNC, be aware that the standard VNC implementation doesn't provide encrypted connection. 警告:如果您使用的是VNC,请注意标准VNC实现不提供加密连接。 So you should use something like ssh tunnel (with putty, or similar) from Windows to Linux, then tunnel your VNC connection through it. 因此,您应该使用从Windows到Linux的ssh隧道(带有腻子或类似的东西),然后通过它建立VNC连接。

Here is how I work in this situation: 在这种情况下,我的工作方式如下:

  1. setup a distant Git repo 设置一个遥远的Git回购
  2. use your regular workstation to edit your code (Windows OS), using the IDE that suits you needs 使用常规工作站,使用适合您需要的IDE来编辑代码(Windows OS)
  3. keep a shell open on your remote Linux machine (SSH) 在远程Linux机器(SSH)上保持外壳打开
  4. As soon as you have something runnable/testable: 一旦您拥有可运行/可测试的功能:
    1. commit your changes and git push commit更改并进行git push
    2. in your Linux Shell: git pull & build ( make ?) 在您的Linux Shell中: git pull &build( make ?)

I just use VirtualBox: 我只是使用VirtualBox:

  1. Create a VM containing your favorite flavor of Linux 创建包含您最喜欢的Linux风格的VM
  2. Create a project in your Windows IDE of choice - I use VS2015 at the mo. 在您选择的Windows IDE中创建一个项目-我现在使用VS2015。
  3. Set the VS project directory as an external mount point/shared folder of the VM. 将VS项目目录设置为VM的外部安装点/共享文件夹。 So all code changes are intrinsically available to the Linux machine. 因此,所有代码更改本质上都可用于Linux计算机。
  4. When its time to compile just alt-tab to the VM windows and type make (assuming you've create your MakeFile ;) ) 当需要编译时,只需alt-tab到VM窗口并键入make(假设您已经创建了MakeFile;))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM