在为项目构建不同的 Eclipse CDT 共享资源文件夹中

发布于 2024-08-15 02:34:53 字数 360 浏览 2 评论 0原文

我有一组 Eclipse c 项目,它们都引用共同的共享代码库(同一文件夹中的 .c 和 .h 文件的混合),但会根据每个项目以不同的方式构建该代码。

可以在每个项目内编辑公共代码库,但这些编辑将是在所有项目中进行的修复。除了通过定义的构建选项之外,每个项目的通用代码不会有所不同。

如果我为此库创建一个项目,则意味着构建的库不是我所需要的。我需要将生成的目标文件放入为其构建的项目中。所以ac/c++项目没有意义。

通用代码将被签入 subversion 存储库(每个项目也是如此)。我可以使用“新文件夹 -> 链接资源”,但我更愿意使项目独立于开发人员恰好使用的目录结构。

有没有一种干净的方法来做到这一点?

谢谢。

I have a set of Eclipse c projects that will all refer to a common shared base of code (a mix of .c and .h files in the same folder) but will be built that code differently on a per project basis.

The common code base may be edited from within each project but these edits will be fixes to be carried across all the projects. The common code will no diverge per project except for build options through defines.

If I create a project for this library it implies a library build with is not what I need. I need the resulting object files to land in the project that they are being built for. So a c/c++ project does not make sense.

The common code will be checked in to a subversion repo (as will each project). I could use "New folder -> Linked resource" but I would prefer to keep the projects independent of the directory structure the developer happens to be using.

Is there a clean way to do this?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

云裳 2024-08-22 02:34:53

我不确定这是否适用于您的 Eclipse 版本或 CDT(我用 Java 测试过),但看来您应该创建第二个源文件夹。由于源文件夹通常对其所在的项目是私有的,因此您必须创建一个链接文件夹...(根据上面的描述,我认为您可能已经这样做了,但为了答案的完整性,我包括以下步骤)。

我是这样做的:

  1. 在项目中创建一个新项目
  2. 选择文件夹(不是源文件夹,而是一个简单文件夹)
  3. 在文件夹创建对话框中单击“高级>>”按钮并选中“链接到文件系统中的文件夹”复选框
  4. 单击“浏览”并选择常见源文件的文件夹
  5. 单击完成

您现在有一个简单的文件夹,但为了在编译中包含该文件夹中的文件(位于至少在 Java 中是这样工作的)您需要创建一个源文件夹:

  1. 在项目中创建一个新项目
  2. 选择“源文件夹”
  3. 单击“文件夹名称”文本框旁边的“浏览”
  4. 选择新创建的链接文件夹

现在,在我的 Eclipse 版本,在 Java 中,该文件夹包含在代码编译中。希望它在 CDT 中的工作方式相同...

如果您运行具有真正符号链接的操作系统(Linux、OSX?),您还可以在项目中使用符号链接文件夹作为额外的源文件夹,然后您应该能够执行上面的“源文件夹”创建步骤。

如果您的 Eclipse 版本在“源文件夹创建”对话框中没有“浏览”按钮,请尝试在文本框中键入相同的名称。

问候,

/E

I'm not sure this will work for your version of Eclipse, or for CDT (I tested it with Java), but it seems you should create a second source folder. Since a source folder are usually private to the project it exists in, you have to create a linked folder... (from your description above I think perhaps you've already done that, but for completeness of the answer I include the steps below).

I did it this way:

  1. Create a new item in your project
  2. Select folder (not a source folder but a simple folder)
  3. In the folder creation dialog click the "Advanced >>" button and check the "Link to folder in file system" check box
  4. Click "Browse" and select the folder of common source files
  5. Click finish

You now have a simple folder, but in order to include the files in the folder in your compilation (at least in Java it works this way) you need to create a source folder:

  1. Create a new item in your project
  2. Select "Source folder"
  3. Click "Browse" next to the "Folder name" text box
  4. Select your newly created linked folder

Now, in my version of Eclipse, and in Java, this folder is included in compilation of the code. It hopefully works the same way in CDT...

If you run an OS with real symbolic links (Linux, OSX?) you may also use a symlinked folder in your project for the extra source folder, and then you should be able to just do the "Source folder"-creation steps above.

If your version of Eclipse do not have a "Browse"-button in the Source Folder creation dialog, try just typing the same name in the text box.

Regards,

/E

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文