我遇到一个问题,包括带有相关.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的任何部分。只编译项目文件夹中的源文件。
我花了几个小时解决这个问题并阅读了很多帖子,但没有找到有效的解决方案。
我想要的是什么:
我已经尝试过:
如果我的问题需要澄清或其他信息,请告诉我。