cancel
Showing results for 
Search instead for 
Did you mean: 

Makefile Linking .o files

TLahr.1
Associate III

I'm trying to use a function from a .c file (that I am trying to add to my project) in another .cpp file (touchGFX project screen.cpp), I included the header file, but I get an "undefined reference" error. I have figured out that this is a linking error, but I don't know how to link the .o files in the Makefile.

I thought maybe putting the .c file into the same directory as the .cpp file would link them during the compilation process, but all it does is put the .o files into the same directory without linking them.

I'm not too familiar with Makefile syntax, especially not how advanced it is in the ToughGFX Makefile, so it's hard for me to discern what is actually going on. Any advice?

1 ACCEPTED SOLUTION

Accepted Solutions
Bob Bailey
Senior

Sounds like you need extern "C" so your c++ call can find the function. There are a couple ways to implement it, I do it like the HAL files .

look at stm32f7xx_it.h and its .c files, they are in the core section.

Bob

View solution in original post

2 REPLIES 2
Bob Bailey
Senior

Sounds like you need extern "C" so your c++ call can find the function. There are a couple ways to implement it, I do it like the HAL files .

look at stm32f7xx_it.h and its .c files, they are in the core section.

Bob

Thank you! This did the trick