Page 1 of 1

ld: cannot perform PE operations on non PE output file.

Posted: Thu Nov 03, 2011 7:01 pm
by kendfrey
I decided to start migrating from assembly language to C for OSdev. I have MinGW installed on my Win7 laptop, and I have been trying to build my kernel, and I am getting the error message above. I have a batch file set up to build everything. The link command is like so:
ld -Ttext 0x10000 --oformat binary -o kernel.bin kernelstart.o kernel.o
How can I get my linker to link the files properly? I think I may need to make a cross-compiler (I even kind of know what that means), and I read the wiki page on GCC Cross-Compiler, but I have no idea how to make one. I looked at crosstool, but it was still full of confusing *nix gobbledy-gook. If I make a cross-compiler, I know I my host is Win7, but I have no idea what my target would be. I would appreciate someone who has done OSdev on Windows to help me with this.

Re: ld: cannot perform PE operations on non PE output file.

Posted: Thu Nov 03, 2011 7:23 pm
by gerryg400
You do need a cross-compiler. And to build a cross-compiler you are recommended to begin by installing Cygwin. Once you have Cygwin it's easy. You can follow the tutorial line-by-line and because the tutorial is tested on Cygwin, it will work.

Re: ld: cannot perform PE operations on non PE output file.

Posted: Thu Nov 03, 2011 9:31 pm
by Brynet-Inc

Re: ld: cannot perform PE operations on non PE output file.

Posted: Fri Nov 04, 2011 9:47 am
by kendfrey
I followed the instructions on the wiki and made a cross compiler. I now have i586-elf versions of cpp, gcc, gcc-4.6.2, and gcov in /usr/local/cross/bin. Shouldn't there be ld and other binutils as well? I can't find them. I noticed something about Error 2 when building binutils. Is that my problem?

Re: ld: cannot perform PE operations on non PE output file.

Posted: Fri Nov 04, 2011 10:37 am
by kendfrey
Tried it again, and it worked. I have my binutils now. Will gcc work if my binutils weren't made when I built it? I will assume so, unless I hear otherwise.

Re: ld: cannot perform PE operations on non PE output file.

Posted: Fri Nov 04, 2011 1:13 pm
by kendfrey
Seems to be working. I have my C kernel running now. :D Thanks everyone!

Re: ld: cannot perform PE operations on non PE output file.

Posted: Fri Nov 04, 2011 2:38 pm
by gerryg400
Well done. Life will be much easier now.

Did you use Cygwin ?

Re: ld: cannot perform PE operations on non PE output file.

Posted: Fri Nov 04, 2011 2:40 pm
by kendfrey
Yes I did. And I must say that although it was confusing to a non-Unixer, I have to recommend it.