Compilation/Link Error with cygwin

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
chrisa128

Compilation/Link Error with cygwin

Post by chrisa128 »

Hi all,

I just started using cygwin after hardware problems with my linux box on which my kernel compiled fine.

However with CYGWIN with gcc, nasm, and make installed I get the following error when it comes to link it...

Code: Select all

PE Operations on non PE file.
collect2: ld returned 1 exit status
make: *** [kernel32] Error 1
Any ideas appreciated people, thanks in advance.
beyondsociety

Re:Compilation/Link Error with cygwin

Post by beyondsociety »

PE Operations on non PE file.
collect2: ld returned 1 exit status
make: *** [kernel32] Error 1
With cygwin, ld isnt compiled to support elf out the gate. You would have to either cross-compile it to supprt elf or what I have done is set the OUTPUT_FORMAT in the linker script to "pe-i386" and compile the kernel to .exe format.

Code: Select all

OUTPUT_FORMAT = pe-i386
kernel_name = kernel.exe
Then use OBJCOPY to convert to whatever file format you want.

Code: Select all

OBJCOPY -O elf32-i386 kernel.exe kernel.elf
Hope this helps.
User avatar
df
Member
Member
Posts: 1076
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

Re:Compilation/Link Error with cygwin

Post by df »

I think I'll put something in the FAQ about this..... it seems to pop up all the time..
-- Stu --
Post Reply