Eclipse CDT的C / C ++:包括从另一个项目的头文件 [英] Eclipse CDT C/C++: Include a header file from another project

查看:414
本文介绍了Eclipse CDT的C / C ++:包括从另一个项目的头文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个C ++项目在Eclipse CDT的主要共享即可。在共享我有一个叫头 calc.h 。我想用这个标题的,所以我做了以下内容:

I have two c++ projects in Eclipse CDT main and shared. In shared i have a header called calc.h. I want to use this header in main, so i did the following:


  • 添加的#includecalc.h 相关文件中的

  • 主要属性 - >项目引用我检查的共享

  • added #include "calc.h to the relevant files in main
  • In main's properties -> Project references i checked of shared

我希望这会工作,但我得到一个致命错误:calc.h:没有这样的文件或目录编译时,因此该项目引用不知何故不工作

I hoped this would work, but I get a fatal error: calc.h: No such file or directory when compiling, so the project reference somehow doesn't work.

我可以得到它'在主要的源文件夹中的属性 - &GT手动添加的共享以工作; C / C ++建设 - >设置 - > GCC C ++反编译>包括,但我的我有一种不好的预感,这将成为较大的项目更复杂的依赖关系繁琐。因此,我会希望Eclipse的可通过项目引用处理这个问题。

I can get it to work by manually adding shared's source folder in main's properties->C/C++ Build->Setting->GCC C++Compiler->Includes, but my i have a bad feeling that this will become cumbersome on larger projects more complex dependencies. I'll therefore hoped that Eclipse could handle this via project references.

我缺少的东西或者是手动的唯一途径?

Am I missing something or is manually the only way?

推荐答案

您是对的,这他做到这一点的方式!

You are right, this his the way to do it !

我使用Eclipse CDT的大项目,但我不使用Eclipse的编译器设置。有一些drawbakcs使用CDT的编译器设置:

I use Eclipse CDT on large project, but I don't use the eclipse compilers settings. There are some drawbakcs to use the CDT compilers settings :


  • 正如你所说,在大型项目中,这是很麻烦。

  • 如果你想编译你的项目不具有日食的平台上(当你部署你的应用程序),这并不简单。

我使用的CMake来管理我的Eclipse项目。
当我开始一个新的项目,我做以下步骤:

I use CMake to manage my eclipse projects. When I start a new project, I do the following steps :


  • 在终端:创建一个文件夹,为新项目

  • 用你喜欢的文本编辑器(VIM,Emacs的,文本编辑,凯特...)创建项目的CMakeLists.txt。您不必创建一个exaustive CMakeLists,只是一个小CMakeLists Four的第一个文件

  • 然后问cmake的生成Eclipse项目感谢:cmake的-G的Eclipse CDT4 - Unix的Makefile文件

  • 开启日食,然后点击文件 - >导入,然后选择一般/现有项目工作区成,那么你可以选择在第一步中创建的文件夹,您的项目准备在Eclipse中使用。

CMake的是编译器的配置工具来管理项目......如果你不知道我鼓励你去发现它。

CMake is THE compiler configuration tool to manage projects... If you don't know it I encourage you to discover it.

干杯!

这篇关于Eclipse CDT的C / C ++:包括从另一个项目的头文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆