Skip to main content
TLahr.1
Associate II
February 10, 2020
Solved

Makefile Linking .o files

  • February 10, 2020
  • 2 replies
  • 1606 views

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?

This topic has been closed for replies.
Best answer by Bob Bailey

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

2 replies

Bob Bailey
Bob BaileyBest answer
Senior
February 11, 2020

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

TLahr.1
TLahr.1Author
Associate II
February 11, 2020

Thank you! This did the trick