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

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
kendfrey
Member
Member
Posts: 45
Joined: Mon Oct 17, 2011 7:44 am

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

Post 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.
gerryg400
Member
Member
Posts: 1801
Joined: Thu Mar 25, 2010 11:26 pm
Location: Melbourne, Australia

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

Post 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.
If a trainstation is where trains stop, what is a workstation ?
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

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

Post by Brynet-Inc »

Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
kendfrey
Member
Member
Posts: 45
Joined: Mon Oct 17, 2011 7:44 am

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

Post 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?
kendfrey
Member
Member
Posts: 45
Joined: Mon Oct 17, 2011 7:44 am

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

Post 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.
kendfrey
Member
Member
Posts: 45
Joined: Mon Oct 17, 2011 7:44 am

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

Post by kendfrey »

Seems to be working. I have my C kernel running now. :D Thanks everyone!
gerryg400
Member
Member
Posts: 1801
Joined: Thu Mar 25, 2010 11:26 pm
Location: Melbourne, Australia

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

Post by gerryg400 »

Well done. Life will be much easier now.

Did you use Cygwin ?
If a trainstation is where trains stop, what is a workstation ?
kendfrey
Member
Member
Posts: 45
Joined: Mon Oct 17, 2011 7:44 am

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

Post by kendfrey »

Yes I did. And I must say that although it was confusing to a non-Unixer, I have to recommend it.
Post Reply