2024-05-11 12:20 PM - last edited on 2024-05-11 01:43 PM by STOne-32
Hello,
I'm working on a project for a Nucleo board for which I'm trying to use VSCode. I've installed the relevant extensions, and building and running the project had been working, but suddenly (after changing the .ioc file in CubeMX) it stopped working (even when I undid my change); now, every time I build or clean build, I get the error:
collect2.exe: error: ld returned 1 exit status
MAKE.EXE: *** [STM32Make.make:211: build/CTS-SAT-1_FW.elf] Error 1
The file in question here seems to say this:
$(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) STM32Make.make
$(CC) $(OBJECTS) $(LDFLAGS) -o $@
$(SZ) $@
Alas, this is entirely incomprehensible to me.
Can anyone help me figure this out?
Thank you!
Solved! Go to Solution.
2024-05-14 04:49 PM - edited 2024-05-14 04:51 PM
Hey there! Thanks for the information.
I found the solution -- when I updated the code using CubeMX in the .ioc file, it removed a number of lines from the makefile which were under C_SOURCES, which without those, VSCode didnt't know where to find the .c files. Adding them back fixed everything!
Thanks again.
2024-05-11 05:54 PM
This means that the linker (ld) failed and returned exit status 1. The makefile itself is not broken.
There should be more detailed log (or previous messages not shown) that explains the linker error.
2024-05-12 12:56 PM
2024-05-12 03:28 PM
A lot of well known library functions can't be found. The project likely does not reference the library files correctly.
If you received this project from other person, ask them to fix. Else, a ready example can help.
2024-05-14 02:04 AM
@hi @DeemDeem52
Could you share your project or ioc
2024-05-14 02:14 AM
@DeemDeem52 wrote:I still don't really understand what the error is, .
An "undefined reference", eg to HAL_UART_Transmit(), means that you have called the function, but have not provided any definition (ie, the implementation; the executable code) for that function.
Usually, this means that you have just #included a header file which contains the prototype for the function - but you haven't included the source file or pre-built binary library which provides the implementation of that function.
For and example of why you need both the header and the source file, see:
In the case of the HAL... functions, they are supplied as source code.
2024-05-14 04:49 PM - edited 2024-05-14 04:51 PM
Hey there! Thanks for the information.
I found the solution -- when I updated the code using CubeMX in the .ioc file, it removed a number of lines from the makefile which were under C_SOURCES, which without those, VSCode didnt't know where to find the .c files. Adding them back fixed everything!
Thanks again.