Page 1 of 1

LD Linker Error

Posted: Tue May 27, 2008 2:52 am
by ollie123
Hello, I am new to this forum, and I'm sorry if I have posted on the wrong board. If so, please tell me where else to post this.

I am new to OS development. I have just used gcc and nasm to create two .o files (one being kernel.o, and the other being main.o).
They both compile fine. However, when I come to use the LD Linker, I get an error:
kernel.o: file not recognized: File format not recognized
This is the command line I am using for LD:
ld -e _begin -Ttext 0x1000 -o first.bin kernel.o main.o
I would appreciate a response.
Cheers, ollie123.

Posted: Tue May 27, 2008 3:17 am
by JamesM
Hi,

Obviously ld doesn't like your object file - could you please post:

* The command line that you use to create that file (the gcc compile line).
* The platform that you are compiling on (linux? cygwin?)
* The output of the command

Code: Select all

file kernel.o
Cheers,

James

Posted: Tue May 27, 2008 3:22 am
by ollie123
For compiling the kernel.o file I am using:
nasm -f aout kernel.asm -o kernel.o
Then the main.o file:
gcc -c main.c -o main.o
And you already know the linker command line.

I am using MinGW.

Thanks for the help.

Posted: Tue May 27, 2008 3:31 am
by JamesM
Hi,

Change your nasm line to

Code: Select all

nasm -f elf kernel.asm -o kernel.o
This should fix your problem.

Cheers,

James

Posted: Tue May 27, 2008 3:35 am
by ollie123
Thanks a lot, it compiles perfectly now.
:D