Eclipse CDT - 将静态资源文件复制到 bin_dir

发布于 2024-08-21 09:11:02 字数 343 浏览 6 评论 0原文

所以我的问题是: 我在 Eclipse 3.5 上的 CDT 6.0 中有一个 C++ 项目,现在有一个静态资源文件(log4cxx 的 .properties)需要复制到构建文件夹中。该文件在运行时访问以配置 log4cxx 子系统,并且它需要与可执行文件位于同一目录中。例如,Debug/ 文件夹中应包含 Debug/Executable 和 Debug/config.properties。

我想要的是让 CDT 在构建时自动将文件从我的 src (或资源)目录复制到 bin 目录。有没有办法在不制作定制目标的情况下做到这一点?我正在使用 Eclipse 管理的 make 项目(或者现在 C++ 可执行文件的默认值),如果这改变了需要设置的方式。

So my problem:
I have a C++ project in CDT 6.0 on Eclipse 3.5, and I now have a static resource file (a .properties for log4cxx) that needs to be copied to the build folder. This file is accessed at runtime to configure the log4cxx subsystem, and it needs to be available in the same directory as the executable. For example, the Debug/ folder should have Debug/Executable and Debug/config.properties in it.

What I would like is to have CDT automatically copy the file from my src (or a resource) directory to the bin directory at build time. Is there a way to do this without making a custom make target? I'm using an Eclipse managed make project (or whatever the default for C++ executable is nowadays), if that changes how things need to be setup.

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

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

发布评论

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

评论(2

十六岁半 2024-08-28 09:11:02

静态资源可以在构建后操作中复制(项目 -> 属性 -> C/C++ 构建 -> 设置 -> 构建步骤

将构建后操作设置为(对于 win):

cmd /c copy ..\res\* .

或者您可以使用 cp for linux 。

The static resources can be copied in post build action (Project -> properties -> C/C++ Build -> Settings -> Build steps

set post-build action to (for win):

cmd /c copy ..\res\* .

or you can use cp for linux.

怪异←思 2024-08-28 09:11:02

好吧...所以我发现 Eclipse 实际上是从根项目文件夹运行可执行文件。我能够在项目下创建一个 config 目录并将我的文件放入其中,因此不再需要将任何属性文件从 src 复制到可执行目录。

Okay... so I figured out that Eclipse was actually running the Executable from the root project folder. I was able to make a config directory under the project and stuff my files in there, so it no longer needs to copy any properties files over from src to the executable directory.

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