error: undefined reference to `calculate()` [How to Solve]

Error Messages:

error: undefined reference to `calculate()`

 

When calling functions in xx.h and xx.c, such as calculate()
are as follows:

#include "xx.h"
int t;
int result = calculate(t);

An error is reported at this time:

error: undefined reference to `calculate()`

 

Solution:

Modify xx.c to xx.cpp, it will be OK!
Guessing that a direct call to xx.h in Qt may not find the definition in xx.c, but only the definition in xx.cpp can be recognized.

Read More: