cancel
Showing results for 
Search instead for 
Did you mean: 

How to add .o file in STM32 cube IDE

Aarra.1
Senior

Hello all,

I have referred the STM32cubeIDE user manual and found the procedure to add the .o file to the project.

I want to call a function from the added .o file.

But I get the following error.

../Core/Src/main.c:130:3: warning: implicit declaration of function 'add2Num' [-Wimplicit-function-declaration]
  130 |   add2Num(1,2);

How can I solve this issue.

1 ACCEPTED SOLUTION

Accepted Solutions
KnarfB
Principal III

> But I get the following error.

No, you get a warning. The compiler doesn't see a declaration of add2Num unless you include a .h file or declared add2Num otherwise. The C compiler assumes that the linker will find your function later while linking. And, this will happen if you link the correct .o file.

hth

KnarfB

View solution in original post

2 REPLIES 2
KnarfB
Principal III

> But I get the following error.

No, you get a warning. The compiler doesn't see a declaration of add2Num unless you include a .h file or declared add2Num otherwise. The C compiler assumes that the linker will find your function later while linking. And, this will happen if you link the correct .o file.

hth

KnarfB

Aarra.1
Senior
extern int add2Num(int num1, int num2);
 
int main()
{
....
}

Thank you KnarfB for ur response.

Yes you are right. I had to declare the function name before the int main()

And it worked.