Problem adding source file to STM32CubeIDE project I can add a .cpp file containing a trivial test function to the Core/Src folder, 'build' seems to process it ok but can not acces this from another source file.
Declaring external function in main.c causes no error
extern plus_one (int) ; // Causes no problem
but from within main ()
int x = plus_one (2); // causes build to fail
11:20:23 **** Incremental Build of configuration Debug for project TemplateL432KC_DMA ****
make -j4 all
arm-none-eabi-g++ "../Core/Src/tesnewfil.cpp" -mcpu=cortex-m4 -std=gnu++14 -g3 -DDEBUG -DUSE_HAL_DRIVER -DSTM32L432xx -c -I../Core/Inc -I../Drivers/STM32L4xx_HAL_Driver/Inc -I../Drivers/STM32L4xx_HAL_Driver/Inc/Legacy -I../Drivers/CMSIS/Device/ST/STM32L4xx/Include -I../Drivers/CMSIS/Include -O0 -ffunction-sections -fdata-sections -fno-exceptions -fno-rtti -fno-use-cxa-atexit -Wall -fstack-usage -MMD -MP -MF"Core/Src/tesnewfil.d" -MT"Core/Src/tesnewfil.o" --specs=nano.specs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -o "Core/Src/tesnewfil.o"
arm-none-eabi-g++ -o "TemplateL432KC_DMA.elf" @"objects.list" -mcpu=cortex-m4 -T"C:\STMCube\TemplateL432KC_DMA\STM32L432KCUX_FLASH.ld" --specs=nosys.specs -Wl,-Map="TemplateL432KC_DMA.map" -Wl,--gc-sections -static --specs=nano.specs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -Wl,--start-group -lc -lm -lstdc++ -lsupc++ -Wl,--end-group
c:\st\stm32cubeide_1.6.1\stm32cubeide\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.9-2020-q2-update.win32_1.5.0.202011040924\tools\arm-none-eabi\bin\ld.exe: Core/Src/main.o: in function `main':
C:/STMCube/TemplateL432KC_DMA/Debug/../Core/Src/main.c:298: undefined reference to `plus_one'
collect2.exe: error: ld returned 1 exit status
make: *** [makefile:80: TemplateL432KC_DMA.elf] Error 1
"make -j4 all" terminated with exit code 2. Build might be incomplete.
