【问题标题】:Eclipse/Neon.2 ignoring a source fileEclipse/Neon.2 忽略源文件
【发布时间】:2017-02-22 16:03:45
【问题描述】:

我正在使用 Eclipse/Neon.2 中的一个 CDT 项目,该项目针对嵌入式目标进行交叉编译。我在项目中添加了一堆 .c 文件,它们会自动包含在构建中,除了(看似)一个。在项目目录中是 STM32F7explore/Utilities/Log/lcd_log.c 其中STM32F7explore 是 Eclipse 项目目录。如果我尝试手动构建它,控制台窗口会显示:

09:45:52 **** Building Selected Files of configuration Debug for project STM32F7explore ****
Info: Internal Builder is used for build

09:45:52 Build Finished (took 1ms)

对于包含的文件,控制台显示例如

09:54:50 **** Building Selected Files of configuration Debug for project STM32F7explore ****
Info: Internal Builder is used for build
arm-none-eabi-gcc -mcpu=cortex-m7 -mthumb -mfloat-abi=hard -mfpu=fpv5-sp-d16 -D__weak=__attribute__((weak)) -D__packed=__attribute__((__packed__)) -DUSE_HAL_DRIVER -DSTM32F746xx -DLWIP_TIMEVAL_PRIVATE=0 -I../Inc -I../Drivers/STM32F7xx_HAL_Driver/Inc -I../Drivers/STM32F7xx_HAL_Driver/Inc/Legacy -I../Drivers/CMSIS/Device/ST/STM32F7xx/Include -I../Drivers/CMSIS/Include -I../Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM7/r0p1 -I../Middlewares/Third_Party/FreeRTOS/Source/include -I../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS -I../Middlewares/Third_Party/LwIP/src/include -I../Middlewares/Third_Party/LwIP/system -I../Middlewares/Third_Party/LwIP/src/include/lwip -I../Middlewares/Third_Party/LwIP/src/include/lwip/apps -I../Middlewares/Third_Party/LwIP/src/include/lwip/priv -I../Middlewares/Third_Party/LwIP/src/include/lwip/prot -I../Middlewares/Third_Party/LwIP/src/include/netif -I../Middlewares/Third_Party/LwIP/src/include/netif/ppp -I../Middlewares/Third_Party/LwIP/src/include/netif/ppp/polarssl -I../Middlewares/Third_Party/LwIP/src/include/posix -I../Middlewares/Third_Party/LwIP/src/include/posix/sys -I../Middlewares/Third_Party/LwIP/system/arch -I../Drivers/BSP/STM32746G_Discovery -I../Utilities/Log -O0 -g3 -Wall -fmessage-length=0 -ffunction-sections -c -fmessage-length=0 -o Src/main.o ../Src/main.c 

09:54:51 Build Finished (took 224ms)

我很困惑为什么 Eclipse 不将 lcd_log.c 文件添加到构建中。我查看了文件属性弹出窗口,它们看起来都一样(特别是,Eclipse 确实将 lcd_log.c 识别为 File (C Source File)

我已经从工作区中删除了.metadata/.plugins/org.eclipse.core.runtime/.settings,并从项目中删除了.settings,以强制 Eclipse 重新生成它们,但这并没有解决问题。

该项目在 Github (https://github.com/HankB/STM32F7explore) 上,但构建要求有点高,除非您碰巧正在为 ST 嵌入式处理器开发。

谢谢!

【问题讨论】:

    标签: c eclipse eclipse-cdt


    【解决方案1】:

    这里发生的是Log(或其父Utilities)目录不是项目源的一部分,而是项目中被排除的额外文件。

    项目浏览器中有一些视觉线索。比较下图中红色的两个框:

    如您所见,Srcdma2d.c 文件使用的图标与 Loglcd_log.c 不同。

    您可以通过右键单击 -> Resource Configurations -> Exclude From Build... 并取消选中 来重新启用文件夹或单个文件在弹出窗口中调试发布,如下所示:

    您还可以通过选择项目属性来控制包含的内容 -> C/C++ 常规 -> 路径和符号 -> 源位置标签。

    我建议不要明确包含 Drivers, Inc 等,而是从根目录开始包含项目中的所有文件。为此,请选择 Source Locations 中的所有现有条目,然后按 Delete。然后,您应该只有一个自动重新创建的条目 /STM32F7Explore,如下所示:(请记住对 Debug 和 Release 进行相同的更改)

    然后,如果您确实想要排除文件/文件夹,请使用资源配置重复上述步骤。 CDT 在这里会很有帮助,如果您在构建中排除的源目录下有单独的文件/文件夹,您将获得另一个图标。这里我排除了一个 C 文件 (log_lcd.c) 和 Fonts 目录:

    Eclipse CDT 的一些具体帮助与上述相关:

    【讨论】:

    • 我添加了一个Pull Request 来显示代码的变化。
    猜你喜欢
    • 2018-10-22
    • 1970-01-01
    • 2016-09-06
    • 1970-01-01
    • 2012-11-09
    • 1970-01-01
    • 2020-11-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多