Skip to main content
Aarra.1
Associate III
February 6, 2023
Solved

How to add .o file in STM32 cube IDE

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.

This topic has been closed for replies.
KnarfB
KnarfBBest answer
Super User
February 6, 2023

> 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

2 replies

KnarfB
KnarfBBest answer
Super User
February 6, 2023

> 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
Aarra.1Author
Associate III
February 6, 2023
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.