Eclipse CDT - 将静态资源文件复制到 bin_dir
所以我的问题是: 我在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
静态资源可以在构建后操作中复制(项目 -> 属性 -> C/C++ 构建 -> 设置 -> 构建步骤
将构建后操作设置为(对于 win):
或者您可以使用 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):
or you can use cp for linux.
好吧...所以我发现 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.