cancel
Showing results for 
Search instead for 
Did you mean: 

Compiler can't find files, even though paths are included

EThom.3
Associate III

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

EThom3_0-1702132473439.png

Path to ../TinyUSB/src is included:

EThom3_1-1702133262402.png

Is there something obvious that I have forgotten? Any help will be greatly appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

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.

TDK_0-1702139985455.png

 

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.

 

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

2 REPLIES 2
TDK
Guru

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.

TDK_0-1702139985455.png

 

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.

 

If you feel a post has answered your question, please click "Accept as Solution".
EThom.3
Associate III

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!