我有以下盒子:
a) 带有 Eclipse CDT 的 Windows 盒子,
b) 一个 Linux 盒子,我只能通过 SSH 访问。
构建和运行我的项目所需的编译器和硬件都只在机器 B 上。
我希望使用 Eclipse CDT 从 Windows 机器上“透明地”工作该项目,并能够远程构建、运行和调试该项目从 IDE 中。
我该如何设置:
- 建筑物能够正常工作?有什么比编写本地 makefile 来 rsync 项目然后调用远程 makefile 来启动实际构建更简单的解决方案吗? Eclipse 托管构建有这方面的功能吗?
- 调试能用吗?
- 最好 - Eclipse CDT 代码索引可以工作吗?我是否必须将所有必需的头文件从机器 B 复制到机器 A 并手动将它们添加到包含路径?
I have the following boxes:
a) A Windows box with Eclipse CDT,
b) A Linux box, accessible for me only via SSH.
Both the compiler and the hardware required to build and run my project is only on machine B.
I'd like to work "transparently" from a Windows box on that project using Eclipse CDT and be able to build, run and debug the project remotely from within the IDE.
How do I set up that:
- The building will work? Any simpler solutions than writing a local makefile which would
rsync
the project and then call a remote makefile to initiate the actual build? Does Eclipse managed build have a feature for that?
- The debugging will work?
- Preferably - the Eclipse CDT code indexing will work? Do I have to copy all required header files from machine B to machine A and add them to include path manually?
发布评论
评论(9)
尝试远程系统资源管理器 (RSE)。它是一组插件,可以完全满足您的需求。
RSE 可能已包含在您当前的 Eclipse 安装中。要检查 Eclipse Indigo,请转到窗口 > 开放的视角 > 其他...,然后从打开透视图对话框中选择远程系统资源管理器以打开 RSE 透视图。
要在 Eclipse 中从 RSE 角度创建 SSH 远程项目,请执行以下操作:
如果操作正确,现在应该有一个新的远程项目,可以从 Project Explorer 和 Eclipse 中的其他透视图访问。正确设置 SSH 连接后,密码可以成为正常 SSH 身份验证过程的可选部分。现在通过 SSH 使用 Eclipse 创建了一个远程项目。
Try the Remote System Explorer (RSE). It's a set of plug-ins to do exactly what you want.
RSE may already be included in your current Eclipse installation. To check in Eclipse Indigo go to Window > Open Perspective > Other... and choose Remote System Explorer from the Open Perspective dialog to open the RSE perspective.
To create an SSH remote project from the RSE perspective in Eclipse:
If done correctly, there should now be a new remote project accessible from the Project Explorer and other perspectives within eclipse. With the SSH connection set-up correctly passwords can be made an optional part of the normal SSH authentication process. A remote project with Eclipse via SSH is now created.
最简单的方法是在 Linux Box 上运行 Eclipse CDT 并使用 X11-Forwarding 或远程桌面软件(例如 VNC)。
当然,只有当 Linux 机器上有 Eclipse 并且与机器的网络连接足够快时,这才有可能。
优点是,由于一切都是本地的,因此您不会遇到同步问题,也不会遇到任何尴尬的跨平台问题。
如果你的盒子上没有 Eclipse,你可以考虑通过 SMB(或 SSHFS)共享你的 Linux 工作目录并从你的 Windows 机器访问它,但这需要相当多的设置。
两者都比拥有两个副本更好,尤其是在跨平台时。
The very simplest way would be to run Eclipse CDT on the Linux Box and use either X11-Forwarding or remote desktop software such as VNC.
This, of course, is only possible when you Eclipse is present on the Linux box and your network connection to the box is sufficiently fast.
The advantage is that, due to everything being local, you won't have synchronization issues, and you don't get any awkward cross-platform issues.
If you have no eclipse on the box, you could thinking of sharing your linux working directory via SMB (or SSHFS) and access it from your windows machine, but that would require quite some setup.
Both would be better than having two copies, especially when it's cross-platform.
我自己(或曾经)处于同一位置,FWIW 最终检查了 Linux 主机上的 samba 共享,并使用 notepad++ 在 Windows 计算机上本地编辑该共享,然后通过 PuTTY 在 Linux 机器上进行编译。 (我们不允许在 Linux 主机上更新编辑器的十个版本,而且它没有 Java,所以我放弃了 X11 转发)
现在......我在我的虚拟机中运行现代 Linux Windows 主机,将我想要的所有工具(例如 CDT)添加到 VM,然后签出并构建与 RTE 非常相似的 chroot 监狱。
这是一个笨重的解决方案,但我想我应该将其加入其中。
I'm in the same spot myself (or was), FWIW I ended up checking out to a samba share on the Linux host and editing that share locally on the Windows machine with notepad++, then I compiled on the Linux box via PuTTY. (We weren't allowed to update the ten y/o versions of the editors on the Linux host and it didn't have Java, so I gave up on X11 forwarding)
Now... I run modern Linux in a VM on my Windows host, add all the tools I want (e.g. CDT) to the VM and then I checkout and build in a chroot jail that closely resembles the RTE.
It's a clunky solution but I thought I'd throw it in to the mix.
我的解决方案与 SAMBA 类似,只是使用 sshfs。使用 sshfs 挂载我的远程服务器,在远程计算机上打开我的 makefile 项目。从那里出发。
看来我也可以通过这种方式运行 Mercurial 的 GUI 前端。
构建我的远程代码就像这样简单: ssh 地址remote_make_command
不过,我正在寻找一种不错的调试方法。可能通过 gdbserver 吗?
My solution is similar to the SAMBA one except using sshfs. Mount my remote server with sshfs, open my makefile project on the remote machine. Go from there.
It seems I can run a GUI frontend to mercurial this way as well.
Building my remote code is as simple as: ssh address remote_make_command
I am looking for a decent way to debug though. Possibly via gdbserver?
我尝试了 ssh -X 但速度慢得难以忍受。
我也尝试过 RSE,但它甚至不支持使用 Makefile 构建项目(我被告知自从我发布了我的答案,但我还没有尝试过)
我读到 NX 比 X11 转发更快,但我无法让它工作。
最后,我发现我的服务器支持 X2Go (链接有安装说明如果你的没有)。现在我只需要:
一切都就像我在本地机器上工作一样,包括构建、调试和代码索引。并且没有明显的滞后。
I tried
ssh -X
but it was unbearably slow.I also tried RSE, but it didn't even support building the project with a Makefile (I'm being told that this has changed since I posted my answer, but I haven't tried that out)
I read that NX is faster than X11 forwarding, but I couldn't get it to work.
Finally, I found out that my server supports X2Go (the link has install instructions if yours does not). Now I only had to:
sudo apt-get install x2goclient
on Ubuntu),Everything is just as if I was working on a local machine, including building, debugging, and code indexing. And there are no noticeable lags.
两年前我遇到了同样的问题,我通过以下方式解决了它:
1)我使用 makefile 构建我的项目,而不是由 eclipse 管理
2) 我使用 SAMBA 连接来编辑 Eclipse 内的文件
3)构建项目:
Eclipse 使用打开 SSH 连接的 makefile 调用“本地”make
到 Linux 主机。在 SSH 命令行上,您可以给出参数
都是在Linux主机上执行的。我使用 makeit.sh shell 脚本作为该参数
它调用 Linux 主机上的“真正的”make。
您还可以通过参数给出不同的构建目标
本地 makefile --> makeit.sh --> Linux 主机上的 makefile。
I had the same problem 2 years ago and I solved it in the following way:
1) I build my projects with makefiles, not managed by eclipse
2) I use a SAMBA connection to edit the files inside Eclipse
3) Building the project:
Eclipse calles a "local" make with a makefile which opens a SSH connection
to the Linux Host. On the SSH command line you can give parameters which
are executed on the Linux host. I use for that parameter a makeit.sh shell script
which call the "real" make on the linux host.
The different targets for building you can give also by parameters from
the local makefile --> makeit.sh --> makefile on linux host.
我解决这个问题的方法是:
对于 Windows:
对于 Linux:
在这两种情况下,您都可以通过 Eclipse 构建和运行,或者通过 ssh 在远程计算机上构建。
The way I solved that one was:
For windows:
For Linux:
In both cases you can either build and run through Eclipse, or build on the remote machine via ssh.
对于这种情况,您可以使用 ptp eclipse https://eclipse.org/ptp/ 进行源代码浏览和构建。
您可以使用此插件来调试应用程序
http://marketplace.eclipse.org/内容/直接远程-c-调试
For this case you can use ptp eclipse https://eclipse.org/ptp/ for source browsing and building.
You can use this pluging to debug your application
http://marketplace.eclipse.org/content/direct-remote-c-debugging
如何在 Eclipse 中进行本地编辑,但使用我编写的基于 git 的脚本 (
sync_git_repo_from_pc1_to_pc2.sh
) 进行同步和构建< /em> 远程执行此答案目前仅适用于使用两台 Linux 计算机 [或者也可能在 Mac 上工作? - 未经 Mac 测试](从一台同步到另一个)因为我在 bash 中编写了这个同步脚本。然而,它只是 git 的包装器,所以请随意将其转换为跨平台的 Python 解决方案或其他东西(如果您愿意的话)。
这并不能直接回答 OP 的问题问题,但它是如此接近,我保证它会回答许多其他登陆此页面的人的问题(实际上包括我的问题,因为我在编写自己的解决方案之前首先来到这里),所以我'无论如何我把它发布在这里。
我想要:
让我们调用第一个我在其中编写代码“PC1”(个人计算机1)的计算机,以及在其中构建代码“PC2”的第二台计算机。我需要一个工具来轻松从 PC1 同步到 PC2。我尝试了 rsync,但对于大型存储库而言,它的速度非常慢,并且占用了大量的带宽和数据。
那么,我该怎么做呢?我应该使用什么工作流程?如果您也有这个问题,这是我决定的工作流程。我编写了一个 bash 脚本来自动化该过程,使用 git 通过远程存储库(例如 github)自动将更改从 PC1 推送到 PC2。到目前为止,它运行得很好,我对此非常满意。 它比 rsync 快得多,在我看来更值得信赖,因为每台 PC 都维护一个功能性的 git 存储库,并且使用更少的带宽来完成整个同步,因此可以轻松地通过手机热点,无需使用大量数据。
设置:
在 PC1 上安装脚本(此解决方案假设 ~/bin 位于您的 $PATH 中):
现在编辑您刚刚在上面复制的“~/.sync_git_repo”文件,并更新其参数以适合您的情况。以下是它包含的参数:
Git 克隆您想要在 PC1 和 PC2 上同步的存储库。
确保您的 ssh 密钥已全部设置为能够从 PC1 和 PC2 推送和拉取远程存储库。以下是一些有用的链接:
确保您的 ssh 密钥已全部设置为从 PC1 到 PC2 的 ssh .
现在
cd
进入 PC1 上 git 存储库中的任意目录,然后运行:就是这样!大约 30 秒后,所有内容都会神奇地从 PC1 同步到 PC2,并且它会一直打印输出,告诉您它正在做什么以及它在磁盘上的哪个位置以及哪台计算机上执行操作。它也很安全,因为它不会覆盖或删除任何未提交的内容。相反,它首先支持它!请阅读下面的更多内容,了解其工作原理。
以下是该脚本使用的流程(即:它实际执行的操作)
rsync
发送到 PC2,并执行ssh
调用来告诉 PC2 使用特殊选项来运行脚本,只执行 PC2 的操作。cd
进入存储库,并检查是否存在任何本地未提交的更改。如果是这样,它会创建一个从当前分支分叉出来的新备份分支(示例名称:my_branch_SYNC_BAK_20200220-0028hrs-15sec
<-- 请注意,这是 YYYYMMDD-HHMMhrs--SSsec),并提交任何未提交的更改到该分支并带有提交消息,例如在 PC2(目标 PC/构建机器)上备份所有未提交的更改。现在,它会检查 SYNC 分支,如果本地计算机上尚不存在该分支,则将其从远程存储库中拉出。然后,它获取远程存储库上的最新更改,并执行硬重置以强制本地 SYNC 存储库与远程 SYNC 存储库匹配。您可以将此称为“硬拉”。不过,它是安全的,因为我们已经在 PC2 上备份了本地所有未提交的更改,因此不会丢失任何内容!资源:
相关:
How to edit in Eclipse locally, but use a
git
-based script I wrote (sync_git_repo_from_pc1_to_pc2.sh
) to synchronize and build remotelyThis answer currently only applies to using two Linux computers [or maybe works on Mac too?--untested on Mac] (syncing from one to the other) because I wrote this synchronization script in bash. It is simply a wrapper around
git
, however, so feel free to take it and convert it into a cross-platform Python solution or something if you wishThis doesn't directly answer the OP's question, but it is so close I guarantee it will answer many other peoples' question who land on this page (mine included, actually, as I came here first before writing my own solution), so I'm posting it here anyway.
I want to:
Let's call the first computer where I write the code "PC1" (Personal Computer 1), and the 2nd computer where I build the code "PC2". I need a tool to easily synchronize from PC1 to PC2. I tried
rsync
, but it was insanely slow for large repos and took tons of bandwidth and data.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 thanrsync
, 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.Setup:
Install the script on PC1 (this solution assumes ~/bin is in your $PATH):
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:
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:
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: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.
Here's the process this script uses (ie: what it's actually doing)
rsync
s a copy of the script over to PC2, and does anssh
call to tell PC2 to run the script with a special option to just do PC2 stuff.cd
s 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!Resources:
Related: