Search code examples
ceclipseeclipse-cdt

Eclipse/Neon.2 ignoring a source file


I'm working with a CDT project in Eclipse/Neon.2 which cross compiles for an embedded target. I've added a bunch of .c files to the project and they are automatically included in the build except for (seemingly) one. In the project directory it is STM32F7explore/Utilities/Log/lcd_log.c where STM32F7explore is the Eclipse project directory. If I try to build it manually, the Console window shows:

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)

For files that are included, the Console shows e.g.

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)

I'm baffled by why Eclipse doesn't add the lcd_log.c file to the build. I've looked at the file properties popup and they look the same for both (and in particular, Eclipse does recognize lcd_log.c as File (C Source File)

I've deleted .metadata/.plugins/org.eclipse.core.runtime/.settings from the workspace and .settings from the project to force Eclipse to regenerate these and that did not fix the problem.

The project is on Github (https://github.com/HankB/STM32F7explore) but the requirements to build are a bit steep unless you happen to be developing for ST embedded processors.

Thanks!


Solution

  • What is going on here is the Log (or its parent Utilities) directory is not part of the source of your project, but rather extra files in the project that are excluded.

    There are some visual clues in the project explorer. Compare the two boxes in red below:

    Src vs Log

    As you can see the Src and dma2d.c files use different icons than Log and lcd_log.c.

    You can re-enable the folder, or individual files, by right-clicking -> Resource Configurations -> Exclude From Build... and unchecking Debug and Release in the pop-up that looks like this:

    exclude from build pop-up

    You can also control what is included by selecting project properties -> C/C++ General -> Paths and Symbols -> Source Locations tab.

    What I would recommend is that rather than having Drivers, Inc, etc be explicitly included, that you include all files in your project starting at the root. To do that, select all the existing entries in Source Locations and press Delete. You should then have just one automatically re-created entry /STM32F7Explore, like this: (Remember to do the same change to both Debug and Release)

    cleaned-up source configuration

    Then, if you actually do want to exclude files/folders, repeat the above steps with Resource Configurations. CDT will be be quite helpful here, if you have individual files/folders under a source directory excluded from the build you will get yet another icon. Here I have excluded a single C file (log_lcd.c) and the Fonts directory:

    exclude the other way

    Some of the specific help for Eclipse CDT that relates to the above: