在Eclipse / avr-gcc中包含外部的,未编译的Header / Source

时间:2018-03-12 14:56:21

标签: c eclipse makefile eclipse-cdt avr-gcc

我遇到一个问题,包括带有相关.c文件的外部标题(在项目文件夹外的文件夹中)和现有项目。

我有几个Atmel AVR微控制器项目。其中一些被打包成一个Git-Repo作为逻辑单元(硬件级)。 公共标题和相关的源文件(例如twi,usart)位于单独的Git-Repos中,它们作为子模块包含在内。

为了快速显示我正在谈论的内容,项目设置如下(- =文件夹,* =文件):

Git-repo_1
  -project_1 (avr-gcc)
      - config (header-files to be included in header-files in the common-folder; project-specific)
          * avr_twimaster_cfg.h
          * avr_twislave_cfg.h
      - share (header-files with project-specific definitions to be included in "project_[2:5]")
          * project_1_interface.h
      - Debug (Build-Config Folder with makefile)
          * makefile
      - Release (Build-Config Folder with makefile)
          * makefile
      * main.h (main project header, includes <avr_twimaster/avr_twimaster.h>, <avr_twimaster/avr_twimaster.h>)
      * main.c (main project source, includes "main.h")
      * functions.c (functions to be used in main.c, includes "main.h")
      * opt. more files
  - project_2 (avr-gcc)
  - project_3 (avr-gcc)
  - project_4 (avr-gcc)
  - project_5 (avr-gcc)
  - common (no toolchain)
      - avr_twimaster (Git-Submodule)
          * avr_twimaster.h (includes <avr_twimaster_cfg.h> from any project)
          * avr_twimaster.c (includes "avr_twimaster.h")
      - avr_twislave (Git-Submodule)
          * avr_twislave.h  (includes <avr_twislave_cfg.h> from any project)
          * avr_twislave.c  (includes "avr_twislave.h")

In&#34; Project-Properties / C,C ++ Build / Settings / Tool Settings / AVR Compiler / Directories&#34;我补充说:

"../../common"
"../share"
"../config"

使用-I将这些路径添加到makefile中&#34; -I ../配置&#34;

  

注意:所有路径都相对于项目文件夹很重要   并包含在makefile中,以便可以编译项目   没有日食或另一台有不同路径的计算机。

我的问题: 甚至eclipse似乎知道在哪里查找包含的头文件:当我按住Ctrl键单击&#34; functions.c&#34;中的函数时,我跳转到正确的标题&#34; avr_twislave.h&#34 ;在&#34; common&#34; -path中。但是按住Ctrl键单击标题中的函数不会跳转到&#34; avr_twislave.c&#34;和副verca。功能名称和参数相同。 &#34; avr_twislave.h&#34;包含在&#34; avr_twislave.c&#34;。

当我尝试编译项目时,我收到很多错误&#34;未定义引用...&#34;这很明显,因为Header和Source之间的连接被打破了。查看控制台,错误发生在链接器部分 - 但我不知道链接器本身是否存在问题,或者它只是无法链接编译器未编译的内容。在编译器输出中,我没有看到common-folder中包含外部header-files / source-files的任何部分。只编译项目文件夹中的源文件。

我花了几个小时解决这个问题并阅读了很多帖子,但没有找到有效的解决方案。

我想要的是什么:

  • 告诉avr-gcc(通过eclipse)使用标题/来源 外部文件夹。
  • 文件夹设置或多或少是关键,因为外部头文件/源文件应该被所有项目和Git-Repo用作子模块。放置&#34; libs&#34;进入项目文件夹不是一个选项。
  • 有关&#34; libs&#34; /文件夹的信息必须在makefile或makefile中包含的其他文件中,而不仅仅是在eclipse中
  • 路径必须相对于project-folder / makefile-folder

我已经尝试过:

  • &#34;工具设置/ AVR编译器/目录中的路径&#34;为索引工作(至少是标题)。
  • &#34; AVR汇编程序&#34;
  • 中的路径
  • &#34; AVR C Linker&#34;
  • 中的路径
  • 无数变体如何在项目文件中包含外部标题
  • &#34;路径和符号下的路径&#34;似乎与工具链选项中的相同,并自动添加。
  • 链接资源似乎绝对是路径
  • 环境变量似乎也是绝对的

如果我的问题需要澄清或其他信息,请告诉我。

0 个答案:

没有答案