ryedwards / budgetcan-fw

Firmware to support gs_usb on most STM32 devices
MIT License
33 stars 8 forks source link

fix linker error #5

Closed paradigmn closed 1 year ago

paradigmn commented 1 year ago

Hi, while trying to compile the firmware I ran into a linker error:

/usr/lib/gcc/arm-none-eabi/12.2.1/../../../arm-none-eabi/bin/ld: build/usbd_gs_can.o: in function `USBD_GS_CAN_DataOut':
/budgetcan_fw/Portable/board_budgetcan_g0/../../Core/Src/usbd_gs_can.c:554: undefined reference to `USBD_GS_CAN_PrepareReceive'
/usr/lib/gcc/arm-none-eabi/12.2.1/../../../arm-none-eabi/bin/ld: /budgetcan_fw/Portable/board_budgetcan_g0/../../Core/Src/usbd_gs_can.c:548: undefined reference to `USBD_GS_CAN_PrepareReceive'
/usr/lib/gcc/arm-none-eabi/12.2.1/../../../arm-none-eabi/bin/ld: build/usbd_gs_can.o: in function `USBD_GS_CAN_Start':
/budgetcan_fw/Portable/board_budgetcan_g0/../../Core/Src/usbd_gs_can.c:300: undefined reference to `USBD_GS_CAN_PrepareReceive'
collect2: error: ld returned 1 exit status
make: *** [Makefile:197: build/budgetcan_g0_fw.elf] Fout 1

This was caused by a missing reference in a header file. Adding the missing prototype fixed the issue for me.

ryedwards commented 1 year ago

The issue is actually due to the lack of a "static" classifier on the USBD_GS_CAN_PrepareReceive() function. We shouldn't need to add the function to the header file as it has local scope. I'll make a change in the .c file to fix this.