본문 바로가기

IT/Basic

'undefined reference' with 'not declared'

 

 

In the first case, you declare a function, but don't define it. It compiles properly, but doesn't link because there is no definition for f. Hence the linker error.

선언만 하고 정의는 하지 않았다. 컴파일은 하지만 링킹은 할 수 없다.

 

In the second case, you attempt to call an undeclared symbol. The compiler doesn't know what f is, so it issues an error. It's a different problem from a different stage of the compilation process, so the message is different.

 

In the third case, you have a well-defined program (except that main fails to return a value). f is both declared and defined. The program should compile, link, and execute properly.

 

 

 

 

'undefined reference' with 'not declared'

this is a simple problem in c compiling and linking. But I want to discuss the principle of compiler and linker. void f(); int main() { f(); } this code receive error message "undefined refer...

stackoverflow.com