compile error

Kai Ruottu
Thu Jun 29 02:37:00 GMT 2000 wrote:
>     I build a necvr4300-elf cross compiler for mips.
>     and try to compile a simple c program then get following error:
> ..../mipsvr4300-elf/bin/ld: cannot open crt0.o
>     No such file or directory
>   collect2:ld return 1 exit status.

 You are trying to compile AND link your program, not just 'compile'
(into a '.s' assembly file using '-S', or into a '.o' object file
using '-c'). For linking you will need a startup-file (crt0.o) and
the C-libraries (libc.a, libm.a,...) in order to get a working

 BTW, how you managed to build 'libgcc.a' without any target headers?
If you haven't the startup and libs, then you probably haven't any
headers either...
> How can I resolve this problem.

 Please get a C-library for your target, e.g. building the Cygnus
'newlib' for your target, or getting some prebuilt libs like those
from the Algorithmics SDE (, they have startup/glue
libs support packages for quite many evaluation etc. boards).

> And whait is a crt0.o,why it's needed.

 Please also get some docs, like the Algorithmics SDE manual, Cygnus
GNUPro docs etc. for these things. Anyhow here is a clip from the
'embed'-one coming with newlib (misc/doc/embed.texi, or something) :

--------------------------- clip -----------------------------------------
The main startup file, crt0

To make a program that has been compiled with GCC to run, you need to
write some startup code. The initial piece of startup code is called
crt0. (C RunTime 0) This is usually written in assembler, and it's
object gets linked in first, and bootstraps the rest of the application
when executed. This file needs to do the following things.

1. Initialize anything that needs it. This init section varies. If you
are developing an application that gets download to a ROM monitor, then
there is usually no need for any special initialization. The ROM monitor
handles it for you.

If you plan to burn your code in a ROM, then the crt0 typically has to do
all the hardware initialization that is required to run an application.
This can include things like initializing serial ports or run a memory
check. It all depends on the hardware.

2. Zero the BSS section. This is for uninitialized data. All the addresses
in this section need to be initialized to zero so that programs that forget
to check new variables default value will get unpredictable results.

3. Call main() This is what basically starts things running. If your ROM
monitor supports it, then first setup argc and argv for command line arguments
and an environment pointer. Then branch to main().  For G++ the the main()
routine gets a branch to __main() inserted by the code generator at the
very top. __main() is used by G++ to initialize it's internal tables.
__main() then returns back to your original main() and your code gets

4. Call exit() After main() has returned, you need to cleanup things and
return control of the hardware from the application. On some hardware, there
is nothing to return to, especially if your program is in ROM.  Sometimes
the best thing to do in this case is do a hardware reset, or branch back
to the start address all over again.
--------------------------- clip -----------------------------------------

Cheers, Kai

Want more information?  See the CrossGCC FAQ,
Want to unsubscribe? Send a note to

More information about the crossgcc mailing list