Linking fpc files error

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
System123
Member
Member
Posts: 196
Joined: Mon Jul 07, 2008 1:25 am

Linking fpc files error

Post by System123 »

I recently converted my os to free pascal. It compiles fine however when i try link the files i get an error 'PE operations in non PE file' or 'kernel.o is an unknown type'. The second one is when i use linux-i386 LD. I link with this command LD -T linker.ld -o kernel.Exe kernel.o console.o
Gizmic OS
Currently - Busy with FAT12 driver and VFS
Laksen
Member
Member
Posts: 140
Joined: Fri Nov 09, 2007 3:30 am
Location: Aalborg, Denmark

Re: Linking fpc files error

Post by Laksen »

Doing this on windows?

Let's see the linker script.

What's your commandline for fpc?
http://j-software.dk | JPasKernel - My Object Pascal kernel
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Re: Linking fpc files error

Post by AJ »

Hi,

I wonder if you would benefit from the GCC Cross-Compiler tutorial? I know you are using Pascal, but perhaps you could just cross compile binutils and use ld from there?

Cheers,
Adam
System123
Member
Member
Posts: 196
Joined: Mon Jul 07, 2008 1:25 am

Re: Linking fpc files error

Post by System123 »

When i compile pascal now it says 'ppc complied for a different system' is this because i am not using linux? If i try link using the win32 version of ld i get a whole bunch of undefined reference errors
Gizmic OS
Currently - Busy with FAT12 driver and VFS
Laksen
Member
Member
Posts: 140
Joined: Fri Nov 09, 2007 3:30 am
Location: Aalborg, Denmark

Re: Linking fpc files error

Post by Laksen »

Could we by any chance see the whole commandline?
http://j-software.dk | JPasKernel - My Object Pascal kernel
leledumbo
Member
Member
Posts: 103
Joined: Wed Apr 23, 2008 8:46 pm

Re: Linking fpc files error

Post by leledumbo »

PE operations in non PE file
I assume you're targetting ELF and you're using ld that comes from MinGW (the one in FPC distribution comes from MinGW). This won't work! Though ld --help shows that it supports ELF, it actually doesn't. You need cross binutils for this (which you already have as i386-linux-ld).
kernel.o is an unknown type
This is because you're compiling the kernel without any -T or -A command line option. The default target for Win32 is of course pe(i)-i386. i386-linux-ld will target elf32-i386, check your linker script for OUTPUT_FORMAT.
System123
Member
Member
Posts: 196
Joined: Mon Jul 07, 2008 1:25 am

Re: Linking fpc files error

Post by System123 »

I compile using -AElf and -TLinux but then FPC gives me the error saying ppc32 was compiled for use on another system :?
Gizmic OS
Currently - Busy with FAT12 driver and VFS
Laksen
Member
Member
Posts: 140
Joined: Fri Nov 09, 2007 3:30 am
Location: Aalborg, Denmark

Re: Linking fpc files error

Post by Laksen »

What's ppc32? Are you sure you have the newest version?
http://j-software.dk | JPasKernel - My Object Pascal kernel
System123
Member
Member
Posts: 196
Joined: Mon Jul 07, 2008 1:25 am

Re: Linking fpc files error

Post by System123 »

Yes i have the latest version. If u go and look in the FPC directory u will see the exe called ppc32 i have no idea what it does. Or why it runs when i use fpc. The other thing is when i use fpc with -Tlinux and -Aelf i get an error saying it can not find the system file used. I will post a shot of the error screen
Gizmic OS
Currently - Busy with FAT12 driver and VFS
System123
Member
Member
Posts: 196
Joined: Mon Jul 07, 2008 1:25 am

Re: Linking fpc files error

Post by System123 »

Ok i finally fixed the problem. My system.o file was not compiled for linux and thus i could not use it. I recompiled it and made the changes and now it works fine. Still one or two bugs to sort out in the includes but im almost done. Thanks for your help
Gizmic OS
Currently - Busy with FAT12 driver and VFS
Post Reply