owennewo / SimpleCAN

A CAN Bus library for Arduino and other platforms
9 stars 2 forks source link

Compile Error #1

Closed MatthewReed303 closed 6 months ago

MatthewReed303 commented 3 years ago

Hi,

I'm having issues compiling for stm32f405 via Arduino framework for stm32 via PlatformIO. Here are the errors I'm getting.

Linking .pio\build\genericSTM32F405RG\firmware.elf c:/users/matthew/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: .pio/build/genericSTM32F405RG/lib2ff/libSimpleCAN.a(SimpleCAN.cpp.o): in functionCAN1_RX0_IRQHandler': SimpleCAN.cpp:(.text.CAN1_RX0_IRQHandler+0x4): undefined reference to HAL_CAN_IRQHandler' c:/users/matthew/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: .pio/build/genericSTM32F405RG/lib2ff/libSimpleCAN.a(SimpleCAN.cpp.o): in functionSimpleCAN::init(int, int, CanSpeed, CanMode)': SimpleCAN.cpp:(.text._ZN9SimpleCAN4initEii8CanSpeed7CanMode+0x84): undefined reference to HAL_CAN_Init' c:/users/matthew/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: .pio/build/genericSTM32F405RG/lib2ff/libSimpleCAN.a(SimpleCAN.cpp.o): in functionSimpleCAN::begin()': SimpleCAN.cpp:(.text._ZN9SimpleCAN5beginEv+0x4): undefined reference to HAL_CAN_Start' c:/users/matthew/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: .pio/build/genericSTM32F405RG/lib2ff/libSimpleCAN.a(SimpleCAN.cpp.o): in functionSimpleCAN::filter(CAN_FilterTypeDef)': SimpleCAN.cpp:(.text._ZN9SimpleCAN6filterEP17CAN_FilterTypeDef+0x4): undefined reference to HAL_CAN_ConfigFilter' c:/users/matthew/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: .pio/build/genericSTM32F405RG/lib2ff/libSimpleCAN.a(SimpleCAN.cpp.o): in functionSimpleCAN::transmit(can_message_t)': SimpleCAN.cpp:(.text._ZN9SimpleCAN8transmitEP13can_message_t+0x1e): undefined reference to HAL_CAN_AddTxMessage' c:/users/matthew/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: .pio/build/genericSTM32F405RG/lib2ff/libSimpleCAN.a(SimpleCAN.cpp.o): in functionSimpleCAN::subscribe(std::function<void (can_message_t*)>)': SimpleCAN.cpp:(.text._ZN9SimpleCAN9subscribeESt8functionIFvP13can_message_tEE+0x56): undefined reference to HAL_CAN_ActivateNotification' collect2.exe: error: ld returned 1 exit status *** [.pio\build\genericSTM32F405RG\firmware.elf] Error 1

flexbrionine commented 1 year ago

Hi, I fixed this by commenting #include in SimpleCAN.cpp in /src folder of your library. That's no longer try to found reference to HAL_CAN_IRQHandler and works great. Actually to fix this property you need some addiction libraries for your stm32. You will need to paste stm32fxxhall*.h to /lib/SimpleCAN-main/src or just comment include in main file. Good luck.

owennewo commented 6 months ago

I'm going to close this issue. I've completely rewritten this library recently, and this issue is 2.5years old (with a workaround provided by flexbrionine)