Page 2 of 2
Re: Need help with multiple C files
Posted: Mon Dec 21, 2015 6:49 am
by moondeck
So, can anyone help me with this error after compiling the kernel with my cross compiler?
Code: Select all
nasm -f elf32 kernelld.asm -o k.o
i686-elf-gcc -m32 -c kernelio/kernelio.c
i686-elf-gcc -m32 -c kernel.c
i686-elf-gcc -m32 -o kernel_main.o kernel.o kernelio.o
/home/moondeck/ccompiler/lib/gcc/i686-elf/5.3.0/../../../../i686-elf/bin/ld: cannot find crt0.o: No such file or directory
/home/moondeck/ccompiler/lib/gcc/i686-elf/5.3.0/../../../../i686-elf/bin/ld: cannot find -lc
collect2: error: ld returned 1 exit status
makefile:2: recipe for target 'kernel' failed
make: *** [kernel] Error 1
Re: Need help with multiple C files
Posted: Mon Dec 21, 2015 8:11 am
by Combuster
Roman wrote:Remove "-m32", add "-ffreestanding".
A kernel is not an userspace application. You'll probably want a linker script as well.
Re: Need help with multiple C files
Posted: Mon Dec 21, 2015 8:40 am
by moondeck
Combuster wrote:Roman wrote:Remove "-m32", add "-ffreestanding".
A kernel is not an userspace application. You'll probably want a linker script as well.
I do have a linker script, i think i have included it in the first post, didnt i?
EDIT: Nope, its here:
Code: Select all
OUTPUT_FORMAT(elf32-i386)
ENTRY(begin)
SECTIONS
{
. = 0x100000;
.text : { *(.text) }
.data : { *(.data) }
.bss : { *(.bss) }
}
Re: Need help with multiple C files
Posted: Mon Dec 21, 2015 9:24 am
by Combuster
What good is a linker script if you're not using it?
Also, you made the
Strings do not work beginner mistake.
Re: Need help with multiple C files
Posted: Mon Dec 21, 2015 9:31 am
by moondeck
Combuster wrote:What good is a linker script if you're not using it?
Also, you made the
Strings do not work beginner mistake.
How can i not be using it if its in my makefile?
Code: Select all
kernel:
nasm -f elf32 kernelld.asm -o k.o
i686-elf-gcc -m32 -c kernelio/kernelio.c
i686-elf-gcc -m32 -c kernel.c
i686-elf-gcc -m32 -o kernel_main.o kernel.o kernelio.o
i686-elf-ld -m elf_i386 -T kernel.ld -o kernel k.o kernel_main.o
Also, the code WORKED before a part of it to kernelio.c and using a cross compiler.
Re: Need help with multiple C files
Posted: Mon Dec 21, 2015 10:00 am
by Combuster
Have you ever manually used a linker on the command line for any reasonably-sized project? You don't seem to understand how the process of compiling and linking is supposed to work (hint: your makefile calls the linker twice).
In addition, I hardly see you fix anything mentioned so far.
Re: Need help with multiple C files
Posted: Mon Dec 21, 2015 10:56 am
by moondeck
Combuster wrote:Have you ever manually used a linker on the command line for any reasonably-sized project? You don't seem to understand how the process of compiling and linking is supposed to work (hint: your makefile calls the linker twice).
In addition, I hardly see you fix anything mentioned so far.
Nope, never used it, i dont really know how it should be configured. I have only programmed microcontrollers before, and it did not require manual linking
Re: Need help with multiple C files
Posted: Mon Dec 21, 2015 11:03 am
by iansjack
Combuster wrote:(hint: your makefile calls the linker twice).
To be strictly accurate, it will only ever call the linker once, but there are two entries for the linker in the makefile.
Re: Need help with multiple C files
Posted: Tue Dec 22, 2015 4:19 am
by Roman
You should learn, how your tools work. Take a look at the gcc man page.