简体   繁体   中英

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. 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. Imagine I want to set up a big C++ project, and now I'm faced with a trouble.

  • 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. (Consider compiling in Windows is not feasible or very slow)
  • 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.

Here I want to exclude some options such as samba , configuring many plugins for vim, or just buy a Mac. And if I write in Windows, it's undesirable to copy the whole contents to remote machine every time syncing with it.

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. I run Qt Creator over the internet and it's instantaneous, so no lags.
  • Option 2: Use VNC only for that program. So create some VNC server and run your IDE in it. This doesn't work for me because the VNC server (realvnc I think) crashes all the time. Maybe you'll be lucky.
  • Option 3: Use VNC with desktop environment. 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).
  • Option 4: Use X2Go as your remote environment. Install the server on your linux, and connect to it with ssh.
  • Option 5: Use xrdp protocol. Install it on linux, and use windows remote desktop to connect to your linux machine from windows.

Warning: If you're using VNC, be aware that the standard VNC implementation doesn't provide encrypted connection. So you should use something like ssh tunnel (with putty, or similar) from Windows to Linux, then tunnel your VNC connection through it.

Here is how I work in this situation:

  1. setup a distant Git repo
  2. use your regular workstation to edit your code (Windows OS), using the IDE that suits you needs
  3. keep a shell open on your remote Linux machine (SSH)
  4. As soon as you have something runnable/testable:
    1. commit your changes and git push
    2. in your Linux Shell: git pull & build ( make ?)

I just use VirtualBox:

  1. Create a VM containing your favorite flavor of Linux
  2. Create a project in your Windows IDE of choice - I use VS2015 at the mo.
  3. Set the VS project directory as an external mount point/shared folder of the VM. So all code changes are intrinsically available to the Linux machine.
  4. When its time to compile just alt-tab to the VM windows and type make (assuming you've create your MakeFile ;) )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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