2023-12-09 06:54 AM
I am trying to implement TinyUSB in an STM32CubeIDE project. My current problem, where I am quite stuck, is that the compiler can't find functions located in the TinyUSB folder tree. Example:
../Core/Src/main.c:176: undefined reference to `tusb_init'
Excerpt from the main.c source file. The header file tusb.h, which has the tusb_init() function prototype, is included.
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include <stdio.h>
#include <string.h>
#include "bsp/board_api.h"
#include "tusb.h"
#include "usb_descriptors.h"
/* USER CODE END Includes */
// Lots of code...
/* USER CODE BEGIN 2 */
tusb_init();
/* USER CODE END 2 */
tusb.c and tusb.h are both located in ../TinyUSB/src
Path to ../TinyUSB/src is included:
Is there something obvious that I have forgotten? Any help will be greatly appreciated.
Solved! Go to Solution.
2023-12-09 08:40 AM
It found the file, otherwise the error message would have been on line 7.
Probably this is a linker error, which means tusb.c isn't being compiled. There should be a gcc statement that compiles it, just like there is one for main.c. Ensure the path to it is include in Project Properties -> C/C++ General -> Paths and Symbols.
If that's not it, include the full context of the error message. The entire "Console" output would be good. Usually the next/previous 10 lines or so along with the error is enough.
2023-12-09 08:40 AM
It found the file, otherwise the error message would have been on line 7.
Probably this is a linker error, which means tusb.c isn't being compiled. There should be a gcc statement that compiles it, just like there is one for main.c. Ensure the path to it is include in Project Properties -> C/C++ General -> Paths and Symbols.
If that's not it, include the full context of the error message. The entire "Console" output would be good. Usually the next/previous 10 lines or so along with the error is enough.
2023-12-09 02:32 PM
Thanks a lot. You are right, of course – the compiler doesn't complain about the #include. I didn't consider that.
Indeed, paths were missing from the "Source Location" list. Adding some paths helped. Now some errors are gone, and others have come up. Not going to spam you with those, and I'm going to stew a bit on those myself.
Thanks again!