Hi all,
I got this error when trying to compile my code
[main] Building folder: test_cmake1_nc - Copy (2)
[build] Starting build
[proc] Executing command: "C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" --build "c:/Users/rsridx/Desktop/test_cmake1_nc - Copy (2)/build" --config Debug --target all --
[build] [1/1 100% :: 0.229] Linking C executable Test
[build] FAILED: Test
[build] cmd.exe /C "cd . && C:\ST\STM32CubeCLT\GNU-tools-for-STM32\bin\arm-none-eabi-gcc.exe -g CMakeFiles/Test.dir/src/s1/helloWorld.c.obj CMakeFiles/Test.dir/src/s2/increment.c.obj -o Test && cd ."
[build] C:/ST/STM32CubeCLT/GNU-tools-for-STM32/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: C:/ST/STM32CubeCLT/GNU-tools-for-STM32/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/lib\libg.a(libc_a-exit.o): in function `exit':
[build] /build/gnu-tools-for-stm32_11.3.rel1.20230912-1600/src/newlib/newlib/libc/stdlib/exit.c:65: undefined reference to `_exit'
[build] C:/ST/STM32CubeCLT/GNU-tools-for-STM32/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: C:/ST/STM32CubeCLT/GNU-tools-for-STM32/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/lib\libg.a(libc_a-closer.o): in function `_close_r':
[build] /build/gnu-tools-for-stm32_11.3.rel1.20230912-1600/src/newlib/newlib/libc/reent/closer.c:47: undefined reference to `_close'
[build] C:/ST/STM32CubeCLT/GNU-tools-for-STM32/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: C:/ST/STM32CubeCLT/GNU-tools-for-STM32/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/lib\libg.a(libc_a-lseekr.o): in function `_lseek_r':
[build] /build/gnu-tools-for-stm32_11.3.rel1.20230912-1600/src/newlib/newlib/libc/reent/lseekr.c:49: undefined reference to `_lseek'
[build] C:/ST/STM32CubeCLT/GNU-tools-for-STM32/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: C:/ST/STM32CubeCLT/GNU-tools-for-STM32/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/lib\libg.a(libc_a-readr.o): in function `_read_r':
[build] /build/gnu-tools-for-stm32_11.3.rel1.20230912-1600/src/newlib/newlib/libc/reent/readr.c:49: undefined reference to `_read'
[build] C:/ST/STM32CubeCLT/GNU-tools-for-STM32/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: C:/ST/STM32CubeCLT/GNU-tools-for-STM32/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/lib\libg.a(libc_a-writer.o): in function `_write_r':
[build] /build/gnu-tools-for-stm32_11.3.rel1.20230912-1600/src/newlib/newlib/libc/reent/writer.c:49: undefined reference to `_write'
[build] C:/ST/STM32CubeCLT/GNU-tools-for-STM32/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: C:/ST/STM32CubeCLT/GNU-tools-for-STM32/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/lib\libg.a(libc_a-sbrkr.o): in function `_sbrk_r':
[build] /build/gnu-tools-for-stm32_11.3.rel1.20230912-1600/src/newlib/newlib/libc/reent/sbrkr.c:51: undefined reference to `_sbrk'
[build] C:/ST/STM32CubeCLT/GNU-tools-for-STM32/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: C:/ST/STM32CubeCLT/GNU-tools-for-STM32/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/lib\libg.a(libc_a-fstatr.o): in function `_fstat_r':
[build] /build/gnu-tools-for-stm32_11.3.rel1.20230912-1600/src/newlib/newlib/libc/reent/fstatr.c:55: undefined reference to `_fstat'
[build] C:/ST/STM32CubeCLT/GNU-tools-for-STM32/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: C:/ST/STM32CubeCLT/GNU-tools-for-STM32/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/lib\libg.a(libc_a-isattyr.o): in function `_isatty_r':
[build] /build/gnu-tools-for-stm32_11.3.rel1.20230912-1600/src/newlib/newlib/libc/reent/isattyr.c:52: undefined reference to `_isatty'
[build] C:/ST/STM32CubeCLT/GNU-tools-for-STM32/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: C:/ST/STM32CubeCLT/GNU-tools-for-STM32/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/lib\libg.a(libc_a-abort.o): in function `abort':
[build] /build/gnu-tools-for-stm32_11.3.rel1.20230912-1600/src/newlib/newlib/libc/stdlib/abort.c:59: undefined reference to `_exit'
[build] C:/ST/STM32CubeCLT/GNU-tools-for-STM32/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: C:/ST/STM32CubeCLT/GNU-tools-for-STM32/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/lib\libg.a(libc_a-signalr.o): in function `_kill_r':
[build] /build/gnu-tools-for-stm32_11.3.rel1.20230912-1600/src/newlib/newlib/libc/reent/signalr.c:53: undefined reference to `_kill'
[build] C:/ST/STM32CubeCLT/GNU-tools-for-STM32/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: C:/ST/STM32CubeCLT/GNU-tools-for-STM32/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/lib\libg.a(libc_a-signalr.o): in function `_getpid_r':
[build] /build/gnu-tools-for-stm32_11.3.rel1.20230912-1600/src/newlib/newlib/libc/reent/signalr.c:83: undefined reference to `_getpid'
[build] collect2.exe: error: ld returned 1 exit status
[build] ninja: build stopped: subcommand failed.
[proc] The command: "C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" --build "c:/Users/rsridx/Desktop/test_cmake1_nc - Copy (2)/build" --config Debug --target all -- exited with code: 1
[driver] Build completed: 00:00:00.301
[build] Build finished with exit code 1
Then I have added a command in my cmakelists.txt file as target_link_libraries(Test -Wl,--start-group -lgcc -lc -lm -lrdimon -Wl,--end-group)
and this has resolved my linker issue!
[main] Configuring project: test_cmake1_nc - Copy (2)
[proc] Executing command: "C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_C_COMPILER:FILEPATH=C:\ST\STM32CubeCLT\GNU-tools-for-STM32\bin\arm-none-eabi-gcc.exe -DCMAKE_CXX_COMPILER:FILEPATH=C:\ST\STM32CubeCLT\GNU-tools-for-STM32\bin\arm-none-eabi-g++.exe "-SC:/Users/rsridx/Desktop/test_cmake1_nc - Copy (2)" "-Bc:/Users/rsridx/Desktop/test_cmake1_nc - Copy (2)/build" -G Ninja
[cmake] Not searching for unused variables given on the command line.
[build] Starting build
[build] Build finished with exit code -1
[cmake] -- Configuring done (0.0s)
[cmake] -- Generating done (0.0s)
[cmake] -- Build files have been written to: C:/Users/rsridx/Desktop/test_cmake1_nc - Copy (2)/build