ARM Technical Support Knowledge Articles

Linker error L6218E: Undefined symbol main (referred from kernel.o).

Applies to: RealView Development Suite (RVDS)

Answer

You may see the following error when linking your application with RVCT 3.0:

Error L6218E: Undefined symbol main (referred from kernel.o).

The linker is reporting that your application does not include a main() function. The error is generated due to changes in the RVCT library code. In RVCT 3.0, a new mechanism has been introduced to select from a number of __user_initial_stackheap() functions in the libraries depending on the layout of your scatter file. Details of how to use this new feature are given in section 5.1.2 of the RVCT 3.0 Linker and Utilities Guide.

Due to the way in which these new functions are implemented, they refer to the __rt_exit() function. This is contained in kernel.o, which also contains the __rt_lib_init() function. As the __rt_lib_init() function calls main(), this results in an undefined symbol error when main() is not present.

The behaviour of calling main() at startup is defined in the ISO C standard, therefore if you do not provide a main function as the entry point of your C code you should be prepared to make allowances for the specific behaviour of the tools. In the case of RVCT 3.0, the simplest solution is to implement an empty, dummy main() function or a dummy implementation of __rt_exit(). If one of these stubs is contained in a separate source file, it will usually be removed by the linker's normal unused section elimination process so there will be no overhead in the final linked image.

Article last edited on: 2008-09-09 15:47:49

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential