2020-11-10 03:38 AM
Background: I have generated a fresh STM32F7 project with mbedtls and I wanted to build a single file from this project (MBEDTLS/App/net_sockets.c).
I followed the steps in https://stackoverflow.com/questions/20023727/eclipse-c-c-cdt-build-just-one-file which allows me to right click the file and build it, unfortunately the build fails with (line numbers are a bit different from the original one since I added a few #pragma message lines):
..\MBEDTLS\App\net_sockets.c:34:10: error: #include expects "FILENAME" or <FILENAME>
#include MBEDTLS_CONFIG_FILE
This is unexpected because the full project builds fine.
But looking at the commands used for building it turns out these are different.
The significant difference for this problem is likely
-DMBEDTLS_CONFIG_FILE=mbedtls_config.h
versus
'-DMBEDTLS_CONFIG_FILE="mbedtls_config.h"'
but there are some other differences, and I have no idea where the single one comes from. If I click properties on the single file and look at the preprocessor settings it shows the version with quotes (same as full project build).
Why does single build has a different command line than project build ? This seems like a bug in CubeIDE (or maybe eclipse in general) ?
Full commands for reference:
When building a the single file:
arm-none-eabi-gcc "..\\MBEDTLS\\App\\net_sockets.c" -mcpu=cortex-m7 -std=gnu11 -g3 -DMBEDTLS_CONFIG_FILE=mbedtls_config.h -DUSE_HAL_DRIVER -DSTM32F745xx -DDEBUG -c -I../Core/Inc "-IZ:\\wptest\\neos2\\Inc\\FSData" -I../LWIP/App -I../LWIP/Target -I../MBEDTLS/App -I../Middlewares/Third_Party/LwIP/src/include -I../Middlewares/Third_Party/LwIP/system -I../Drivers/STM32F7xx_HAL_Driver/Inc -I../Drivers/STM32F7xx_HAL_Driver/Inc/Legacy -I../Middlewares/Third_Party/FreeRTOS/Source/include -I../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2 -I../Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM7/r0p1 -I../Middlewares/Third_Party/LwIP/src/include/netif/ppp -I../Middlewares/Third_Party/LwIP/src/apps/http -I../Drivers/CMSIS/Device/ST/STM32F7xx/Include -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/compat/posix -I../Middlewares/Third_Party/LwIP/src/include/compat/posix/arpa -I../Middlewares/Third_Party/LwIP/src/include/compat/posix/net -I../Middlewares/Third_Party/LwIP/src/include/compat/posix/sys -I../Middlewares/Third_Party/LwIP/src/include/compat/stdc -I../Middlewares/Third_Party/LwIP/system/arch -I../Middlewares/Third_Party/mbedTLS/include/mbedtls -I../Middlewares/Third_Party/mbedTLS/include -I../Drivers/CMSIS/Include -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage --specs=nano.specs -mfpu=fpv5-sp-d16 -mfloat-abi=hard -mthumb -o "MBEDTLS\\App\\net_sockets.o"
When building the file as part of a full project build:
arm-none-eabi-gcc "../MBEDTLS/App/net_sockets.c" -mcpu=cortex-m7 -std=gnu11 -g3 '-DMBEDTLS_CONFIG_FILE="mbedtls_config.h"' -DUSE_HAL_DRIVER -DSTM32F745xx -DDEBUG -c -I../Core/Inc -I"Z:/wptest/neos2/Inc/FSData" -I../LWIP/App -I../LWIP/Target -I../MBEDTLS/App -I../Middlewares/Third_Party/LwIP/src/include -I../Middlewares/Third_Party/LwIP/system -I../Drivers/STM32F7xx_HAL_Driver/Inc -I../Drivers/STM32F7xx_HAL_Driver/Inc/Legacy -I../Middlewares/Third_Party/FreeRTOS/Source/include -I../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2 -I../Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM7/r0p1 -I../Middlewares/Third_Party/LwIP/src/include/netif/ppp -I../Middlewares/Third_Party/LwIP/src/apps/http -I../Drivers/CMSIS/Device/ST/STM32F7xx/Include -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/compat/posix -I../Middlewares/Third_Party/LwIP/src/include/compat/posix/arpa -I../Middlewares/Third_Party/LwIP/src/include/compat/posix/net -I../Middlewares/Third_Party/LwIP/src/include/compat/posix/sys -I../Middlewares/Third_Party/LwIP/src/include/compat/stdc -I../Middlewares/Third_Party/LwIP/system/arch -I../Middlewares/Third_Party/mbedTLS/include/mbedtls -I../Middlewares/Third_Party/mbedTLS/include -I../Drivers/CMSIS/Include -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -MMD -MP -MF"MBEDTLS/App/net_sockets.d" -MT"MBEDTLS/App/net_sockets.o" --specs=nano.specs -mfpu=fpv5-sp-d16 -mfloat-abi=hard -mthumb -o "MBEDTLS/App/net_sockets.o"