BL51: UNRESOLVED SYMBOL ?C_STARTUP
Information in this article applies to:
- C51 All Versions
SYMPTOMS
When writing single-file projects using in-line assembly, the linker produces the following warning:
*** WARNING L1: UNRESOLVED EXTERNAL SYMBOL SYMBOL: ?C_STARTUP MODULE: main.obj (MAIN)
For example, the following program:
#include <reg52.h> void main() { unsigned char i; unsigned char cur[20]; for( i = 0; i < 20; i++) { #pragma asm mov A, x; movc A, @A+PC; #pragma endasm } }
When compiled, assembled, and linker in µVision2, generates the warning above. To translate this file, you must enable the following 2 checkboxes in Project - Options for file - Properties:
- Generate Assembler SRC File
- Assembler SRC File
CAUSE
When you compile all your C modules with the SRC directive and the assembler, the linker does not detect the required C run-time libraries (because the files were assembled). In this case, you must add the libraries to your project manually.
RESOLUTION
For a project in the SMALL memory model that uses no floating point arithmetic, C51S.LIB is required.
For a project in the LARGE memory model that uses floating-point, C51FPL.LIB and C51L.LIB are required.
If a project uses floating arithmetic, it is important that C51FPx.LIB is included before the standard library file C51x.LIB. Otherwise printf and scanf will not work with floating-point numbers.
When you are using µVision, you may simply add the require library file(s) to the project in the same way as you are adding source files.