[Help] Meaty skeleton won't compile "cannot stat crtbegin.o"

All about the OSDev Wiki. Discussions about the organization and general structure of articles and how to use the wiki. Request changes here if you don't know how to use the wiki.
Post Reply
User avatar
Sophite
Posts: 9
Joined: Wed May 10, 2017 1:54 pm

[Help] Meaty skeleton won't compile "cannot stat crtbegin.o"

Post by Sophite »

After adding a bunch of stuff to libc and after fixing a bunch of crap on OSX to get stuff to work, I run into this.

Code: Select all

cp: cannot stat 'crtbegin.o': No such file or directory
make: *** [Makefile:60: arch/i386/crtbegin.o] Error 1

Tested on unmodified git cloned meaty skeleton, same result.
no92
Member
Member
Posts: 306
Joined: Wed Oct 30, 2013 1:57 pm
Libera.chat IRC: no92
Location: Germany
Contact:

Re: [Help] Meaty skeleton won't compile "cannot stat crtbegi

Post by no92 »

Stating the obvious: the file is missing, i.e. not at the path Make expects it to be.

My crystal ball tells me that you either forgot the rules to find and copy the file or messed up your gcc call.

To help us out, what is printed when you run

Code: Select all

/path/to/your/cross/gcc $(CFLAGS) -print-file-name=crtbegin.o
and what is your Makefile rule to get the crt[begin|end].o files?

EDIT: Meaty Skeleton compiles and appears to work flawlessly on my box. I'm running an i686-elf-gcc, version 7.1.0, compiled from source. IIRC gcc on macOS is actually a symlink to clang. Make sure you're actually using a gcc. If you're running gcc, what version are you on?
User avatar
sortie
Member
Member
Posts: 930
Joined: Wed Mar 21, 2012 3:01 pm
Libera.chat IRC: sortie

Re: [Help] Meaty skeleton won't compile "cannot stat crtbegi

Post by sortie »

Hi, I wrote that example operating system.

You've got to specify a lot of more information if you want help. For instance, what exactly you did to get it working on OS X, whether you are using a cross-compiler, how you are invoking the build script, a copy of the entire shell history for a session that reproduces this issue (and most importantly shows the make output).

The code in question should be
$(ARCHDIR)/crtbegin.o $(ARCHDIR)/crtend.o:
OBJ=`$(CC) $(CFLAGS) $(LDFLAGS) -print-file-name=$(@F)` && cp "$$OBJ" $@
Since $@ will expand to arch/i386/crtbegin.o, the cp command will have to be ”cp crtbegin.o arch/i386/crtbegin.o” to trigger the error you have. That means $(CC) $(CFLAGS) $(LDFLAGS) -print-file-name=crtbegin.o expanded to crtbegin.o. In other words, your compiler failed to locate a crtbegin.o.

I will guess that you are either not using a cross-compiler (and you need to do that), or you forgot to build libgcc as part of your cross-compiler build. You will need to read and follow the instructions at http://wiki.osdev.org/GCC_Cross-Compiler very carefully.

Note that Meaty Skeleton is not supported for OS X. It's just an example, so I have cut away OS X support as OS X fails at many basic Unix things that would unnecessarily complicate things. It is more BSD friendly as of late, but there's still some ways to go there I think. I need to revise it to keep up more with my current recommendations. I hope it's of use to you.
Post Reply