我有以下盒子:

a)装有Eclipse CDT的Windows盒子, b)一个Linux盒子,我只能通过SSH访问。

编译器和构建和运行我的项目所需的硬件都只在机器B上。

我希望使用Eclipse CDT在Windows系统中“透明地”工作,并且能够在IDE中远程构建、运行和调试项目。

我如何设置它:

这幢大楼能工作吗?还有比编写本地makefile更简单的解决方案吗?这个本地makefile会对项目进行rsync,然后调用远程makefile来初始化实际的构建?Eclipse托管构建有相应的特性吗? 调试会工作吗? 最好- Eclipse CDT代码索引将工作?我是否必须将所有必需的头文件从机器B复制到机器A,并手动将它们添加到include路径?


当前回答

我尝试了ssh -X,但它慢得令人难以忍受。

我也尝试了RSE,但它甚至不支持用Makefile构建项目(我被告知,这已经改变了,因为我张贴了我的答案,但我还没有尝试过)

我读到NX的转发速度比X11快,但我不能让它工作。

最后,我发现我的服务器支持X2Go(如果你的服务器不支持,链接上有安装说明)。现在我只需要:

在服务器上下载并解包Eclipse, 在我的本地机器上安装X2Go (sudo apt-get install x2goclient on Ubuntu), 配置连接(主机,ssh密钥自动登录,选择运行Eclipse)。

一切就像我在一台本地机器上工作一样,包括构建、调试和代码索引。而且没有明显的滞后。

其他回答

如何在Eclipse中本地编辑,但使用我编写的基于git的脚本(sync_git_repo_from_pc1_to_pc2.sh)来同步和远程构建

我为此编写的脚本是sync_git_repo_from_pc1_to_pc2.sh。 自述:README_git-sync_repo_from_pc1_to_pc2.md 更新:参见这个替代/竞争对手:GitSync: 如何在SSH上使用Sublime https://github.com/jachin/GitSync

这个答案目前只适用于使用两台Linux电脑[或者也适用于Mac电脑?]——未在Mac上测试](从一个同步到另一个),因为我用bash写了这个同步脚本。不过,它只是一个git的包装器,所以如果您愿意,可以随意将其转换为跨平台的Python解决方案或其他东西


这并没有直接回答OP的问题,但它是如此接近,我保证它会回答许多其他登陆这个页面的人的问题(实际上,包括我的,因为我是在写我自己的解决方案之前先来这里的),所以我还是把它贴在这里。

我想:

然后在轻量级Linux计算机上使用强大的IDE(如Eclipse)开发代码 在另一台功能更强大的Linux计算机上通过ssh构建代码(从命令行,而不是从Eclipse内部)

让我们把我写代码的第一台计算机称为“PC1”(个人计算机1),把我写代码的第二台计算机称为“PC2”。我需要一个工具来轻松地从PC1同步到PC2。我尝试了rsync,但是对于大型回购来说,它太慢了,而且占用了大量的带宽和数据。

So, how do I do it? What workflow should I use? If you have this question too, here's the workflow that I decided upon. I wrote a bash script to automate the process by using git to automatically push changes from PC1 to PC2 via a remote repository, such as github. So far it works very well and I'm very pleased with it. It is far far far faster than rsync, more trustworthy in my opinion because each PC maintains a functional git repo, and uses far less bandwidth to do the whole sync, so it's easily doable over a cell phone hot spot without using tons of your data.

设置:

Install the script on PC1 (this solution assumes ~/bin is in your $PATH): git clone https://github.com/ElectricRCAircraftGuy/eRCaGuy_dotfiles.git cd eRCaGuy_dotfiles/useful_scripts mkdir -p ~/bin ln -s "${PWD}/sync_git_repo_from_pc1_to_pc2.sh" ~/bin/sync_git_repo_from_pc1_to_pc2 cd .. cp -i .sync_git_repo ~/.sync_git_repo Now edit the "~/.sync_git_repo" file you just copied above, and update its parameters to fit your case. Here are the parameters it contains: # The git repo root directory on PC2 where you are syncing your files TO; this dir must *already exist* # and you must have *already `git clone`d* a copy of your git repo into it! # - Do NOT use variables such as `$HOME`. Be explicit instead. This is because the variable expansion will # happen on the local machine when what we need is the variable expansion from the remote machine. Being # explicit instead just avoids this problem. PC2_GIT_REPO_TARGET_DIR="/home/gabriel/dev/eRCaGuy_dotfiles" # explicitly type this out; don't use variables PC2_SSH_USERNAME="my_username" # explicitly type this out; don't use variables PC2_SSH_HOST="my_hostname" # explicitly type this out; don't use variables Git clone your repo you want to sync on both PC1 and PC2. Ensure your ssh keys are all set up to be able to push and pull to the remote repo from both PC1 and PC2. Here's some helpful links: https://help.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh https://help.github.com/en/github/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent Ensure your ssh keys are all set up to ssh from PC1 to PC2. Now cd into any directory within the git repo on PC1, and run: sync_git_repo_from_pc1_to_pc2 That's it! About 30 seconds later everything will be magically synced from PC1 to PC2, and it will be printing output the whole time to tell you what it's doing and where it's doing it on your disk and on which computer. It's safe too, because it doesn't overwrite or delete anything that is uncommitted. It backs it up first instead! Read more below for how that works.

下面是这个脚本使用的过程(即:它实际上在做什么)

From PC1: It checks to see if any uncommitted changes are on PC1. If so, it commits them to a temporary commit on the current branch. It then force pushes them to a remote SYNC branch. Then it uncommits its temporary commit it just did on the local branch, then it puts the local git repo back to exactly how it was by staging any files that were previously staged at the time you called the script. Next, it rsyncs a copy of the script over to PC2, and does an ssh call to tell PC2 to run the script with a special option to just do PC2 stuff. Here's what PC2 does: it cds into the repo, and checks to see if any local uncommitted changes exist. If so, it creates a new backup branch forked off of the current branch (sample name: my_branch_SYNC_BAK_20200220-0028hrs-15sec <-- notice that's YYYYMMDD-HHMMhrs--SSsec), and commits any uncommitted changes to that branch with a commit message such as DO BACKUP OF ALL UNCOMMITTED CHANGES ON PC2 (TARGET PC/BUILD MACHINE). Now, it checks out the SYNC branch, pulling it from the remote repository if it is not already on the local machine. Then, it fetches the latest changes on the remote repository, and does a hard reset to force the local SYNC repository to match the remote SYNC repository. You might call this a "hard pull". It is safe, however, because we already backed up any uncommitted changes we had locally on PC2, so nothing is lost! That's it! You now have produced a perfect copy from PC1 to PC2 without even having to ensure clean working directories, as the script handled all of the automatic committing and stuff for you! It is fast and works very well on huge repositories. Now you have an easy mechanism to use any IDE of your choice on one machine while building or testing on another machine, easily, over a wifi hot spot from your cell phone if needed, even if the repository is dozens of gigabytes and you are time and resource-constrained.

资源:

整个项目:https://github.com/ElectricRCAircraftGuy/eRCaGuy_dotfiles 在这个项目的源代码中看到更多的链接和引用。 如何做一个“硬拉”,正如我所说的:我如何迫使“git拉”覆盖本地文件?

相关:

Git仓库在计算机之间同步,当移动?

我的解决方案与SAMBA类似,只是使用了sshfs。用sshfs挂载远程服务器,在远程机器上打开makefile项目。从那里开始。

似乎我也可以用这种方式运行mercurial的GUI前端。

构建远程代码非常简单:ssh address remote_make_command

我正在寻找一种合适的方法来调试。可能通过gdbserver?

我自己也在同样的地方(或者曾经是),我最终签出了Linux主机上的samba共享,并在Windows机器上使用notepad++在本地编辑共享,然后我通过PuTTY在Linux盒子上编译。(我们不允许在Linux主机上更新10个y/o版本的编辑器,它没有Java,所以我放弃了X11转发)

现在…我在Windows主机上的VM中运行现代Linux,将我想要的所有工具(例如CDT)添加到VM中,然后在与RTE非常相似的chroot jail中签出和构建。

这是一个笨拙的解决方案,但我想我应该把它加入到混合中。

试试远程系统资源管理器(RSE)。它是一组插件,可以做您想做的事情。

RSE可能已经包含在当前的Eclipse安装中。要检查Eclipse Indigo,请到窗口>打开透视图>其他…并从打开透视图对话框中选择远程系统资源管理器来打开RSE透视图。

在Eclipse中从RSE透视图创建SSH远程项目:

定义一个新的连接,并在“新建连接”对话框中的“选择远程系统类型”窗口中选择“仅使用SSH”。 输入连接信息,然后选择Finish。 连接新主机。(假设SSH密钥已经设置。) 一旦连接,钻到主机的Sftp文件,选择一个文件夹,并从该项的上下文菜单中选择Create Remote Project。(在创建远程项目时等待。)

如果操作正确,现在应该有一个可以从project Explorer和eclipse中的其他透视图访问的新的远程项目。正确设置SSH连接后,密码可以成为正常SSH身份验证过程的可选部分。现在,通过SSH使用Eclipse创建了一个远程项目。

我解决这个问题的方法是:

windows:

使用samba从Linux机器导出“workspace”目录。 在本地窗口中挂载它。 运行Eclipse,使用挂载的“workspace”目录作为Eclipse工作空间。 导入您想要的项目并对其进行处理。

Linux:

使用sshfs挂载“workspace”目录 运行Eclipse。 运行Eclipse,使用挂载的“workspace”目录作为Eclipse工作空间。 导入您想要的项目并对其进行处理。

在这两种情况下,您既可以通过Eclipse构建和运行,也可以通过ssh在远程机器上构建。