[prog] error: "reference 'main' can not be resolved"
Tim King
timk at jtse.com
Thu Nov 10 03:34:54 EST 2005
Asl? <gosalyn at gmail.com> wrote:
> for my system programming course, i'd like to learn whether the linker or
> the loader causes this pseudo-error message:
> " reference 'main' can not be resolved" , and what causes this error.
Hi, Asli. What language are you using? C, C++, Java, or what? Also, what
compiler or development environment are you using?
In C or C++, a message like this typically means the linker cannot find
the main() function. In C, it doesn't matter what formal parameters
main() takes, though your program may do funny things or crash if you
use the wrong ones. In C++, the /compiler/ should chide you if you get
the formal parameters wrong, with a more specific message, before you
even get to the linking stage.
In a language like Java, symbol references are resolved at run-time when
the virtual machine links the class into the running program, after the
class loader loads the class. The run-time would complain if it can't
find a suitable main(). This could be (for example) because you forgot
to declare it static, didn't provide suitable formal parameters, or
misspelled the class name.
-TimK
--
J. Timothy King
www.jtse.com
More information about the Programming
mailing list