Difference between revisions of "Cross compiling/de"

From Free Pascal wiki
Jump to navigationJump to search
 
m
Line 1: Line 1:
 +
{{Cross compiling}}
 +
 
=Vorwort=
 
=Vorwort=
 
Dies ist eine kurze Einführung für Neulinge. Die folgenden Abschnitte beschreiben, wie man ein System für cross compile einrichtet, das bedeutet, arbeiten unter Linux und erzeugen von von Win32 executables (oder freebsd oder darwin, oder ...). FreePascal ist ein Compiler und konvertiert hauptsächlich Quellcode in binaries (Maschinensprache). Diese binaries enthalten auch Informationen darüber, wie das Betriebssystem das executable startet. Daher sind diese binaries Plattform-spezifisch. FreePascal selbst benötigt nicht viel Installation. Es kann binaries für viele Plattformen erzeugen. Just tell it to do so. Aber der Compiler ist nur ein Teil. Es gibt auch noch den Assembler und den Linker. Und diese Werkzeuge sind nicht in der Lage, cross code zu erzeugen. Daher müssen wir spezielle Linker 'ld' und Assembler 'as' für jede Zielplattform erzeugen. Dies sind die binutils. Nach Erstellung der cross tools, werden alle FPC Pascal Units cross compiled. Zum Beispiel, dann gibt es eine system.ppu Datei für jede Zielplattform. TDann wird ihre FPC Konfigurationsdatei eingerichtet, so daß cross compilation so einfach wird, daß sie alle langweiligen Details vergessen können. Das selbe wird für die LCL getan - die lazarus component library. Und danach können sie cross compile Pascal Programme für Win32. Entweder starten sie sie mit Wine oder sie kopieren sie auf eine Windows maschine und testen sie dort.
 
Dies ist eine kurze Einführung für Neulinge. Die folgenden Abschnitte beschreiben, wie man ein System für cross compile einrichtet, das bedeutet, arbeiten unter Linux und erzeugen von von Win32 executables (oder freebsd oder darwin, oder ...). FreePascal ist ein Compiler und konvertiert hauptsächlich Quellcode in binaries (Maschinensprache). Diese binaries enthalten auch Informationen darüber, wie das Betriebssystem das executable startet. Daher sind diese binaries Plattform-spezifisch. FreePascal selbst benötigt nicht viel Installation. Es kann binaries für viele Plattformen erzeugen. Just tell it to do so. Aber der Compiler ist nur ein Teil. Es gibt auch noch den Assembler und den Linker. Und diese Werkzeuge sind nicht in der Lage, cross code zu erzeugen. Daher müssen wir spezielle Linker 'ld' und Assembler 'as' für jede Zielplattform erzeugen. Dies sind die binutils. Nach Erstellung der cross tools, werden alle FPC Pascal Units cross compiled. Zum Beispiel, dann gibt es eine system.ppu Datei für jede Zielplattform. TDann wird ihre FPC Konfigurationsdatei eingerichtet, so daß cross compilation so einfach wird, daß sie alle langweiligen Details vergessen können. Das selbe wird für die LCL getan - die lazarus component library. Und danach können sie cross compile Pascal Programme für Win32. Entweder starten sie sie mit Wine oder sie kopieren sie auf eine Windows maschine und testen sie dort.

Revision as of 22:19, 11 February 2006

Deutsch (de) English (en) español (es) français (fr) magyar (hu) português (pt) русский (ru) 中文(中国大陆)‎ (zh_CN) 中文(台灣)‎ (zh_TW)

Vorwort

Dies ist eine kurze Einführung für Neulinge. Die folgenden Abschnitte beschreiben, wie man ein System für cross compile einrichtet, das bedeutet, arbeiten unter Linux und erzeugen von von Win32 executables (oder freebsd oder darwin, oder ...). FreePascal ist ein Compiler und konvertiert hauptsächlich Quellcode in binaries (Maschinensprache). Diese binaries enthalten auch Informationen darüber, wie das Betriebssystem das executable startet. Daher sind diese binaries Plattform-spezifisch. FreePascal selbst benötigt nicht viel Installation. Es kann binaries für viele Plattformen erzeugen. Just tell it to do so. Aber der Compiler ist nur ein Teil. Es gibt auch noch den Assembler und den Linker. Und diese Werkzeuge sind nicht in der Lage, cross code zu erzeugen. Daher müssen wir spezielle Linker 'ld' und Assembler 'as' für jede Zielplattform erzeugen. Dies sind die binutils. Nach Erstellung der cross tools, werden alle FPC Pascal Units cross compiled. Zum Beispiel, dann gibt es eine system.ppu Datei für jede Zielplattform. TDann wird ihre FPC Konfigurationsdatei eingerichtet, so daß cross compilation so einfach wird, daß sie alle langweiligen Details vergessen können. Das selbe wird für die LCL getan - die lazarus component library. Und danach können sie cross compile Pascal Programme für Win32. Entweder starten sie sie mit Wine oder sie kopieren sie auf eine Windows maschine und testen sie dort.

Grundsätzliche Schritte

Es gibt einige übliche Schritte, die beteiligt sind in crosscompiling, die sie in jedem Fall tun müssen:

  1. Bereits einen FreePascal Compiler haben für die Plattform, von der sie kompilieren wollen.
  2. Sie müssen den FreePascal Quellcode haben.
  3. You need to either build from source or obtain binaries of the cross-binutils that run on the platform you are on and are designed to build programs for your desired target platform.
  4. Manchmal werden sie einige Dateien benötigen von der Zielplattform, zu der sie kompilieren.

Von Linux

Zu Windows

Cross_compiling_for_Win32_under_Linux

Zu Darwin oder Apple

  • First you need the binutils for the platform you want to compile to. Download odcctools from this site (use the cvs version) and follow their instructions for installing. http://www.opendarwin.org/projects/odcctools/
  • you need to create a fake root dir like: $HOME/darwinroot copy at least the /System and /Frameworks and /usr directories (you may have to copy more than this) from your Apple or Darwin computer to $HOME/darwinroot
  • now that you have these files make a folder in $HOME/darwinroot called cross. where ever you installed the odcctools you need to make links for the cross tools to be more fpc friendly. there are a bunch of files from odcc tools called powerpc-apple-darwin-* you need to make links (or rename them) so powerpc-apple-darwin-ld becomes powerpc-darwin-ld, do the same for *-ar and *-as.
  • now you are ready to crosscompile fpc. basically you need to have the fpc source and have a terminal open there.

type:

$PATH=$PATH:$HOME/darwinroot/cross (or whereever you made the symlinks)

type (iirc):

make all TARGET_OS=darwin TARGET_CPU=powerpc OPT="-Xd -Fl/$HOME/darwinroot/usr/lib"

if that succeded you can install it to whereever you want with:

make install TARGET_OS=darwin TARGET_CPU=powerpc PREFIX=/cross/fpc

now copy the file ./compiler/ppccross somewhere you will be able to find it as it's the compiler you'll need to build powerpc programs

  • configure your /etc/fpc.cfg file.

add a section like this:

#IFDEF powerpc
-Fu/cross/fpc/lib/fpc/$fpcversion/units/$fpctarget/
-Fu/cross/fpc/lib/fpc/$fpcversion/units/$fpctarget/rtl
-Fu/cross/fpc/lib/fpc/$fpcversion/units/$fpctarget/*
-k-systemroot $HOME/darwin/cross
#ENDIF

whenever you want to crosscompile you have to have ppccross and the symlinks to powerpc-darwin-* in the PATH and you should be able to just do ppccross someprogie.pas and it will create a darwin executable.

I may have mistated some things (or most everything) as it's been a while since I did this.

Von Windows

Zu Linux

Marco vd Voort schrieb einige crossnotes. Wenn jemand Zeit hat, dann kann er sie diesem Wiki hinzufügen.

Cross compile FAQ

Warum cross compile?

Damit können sie ein Programm entwickeln für ein Betriebssystem/CPU und es kompilieren für ein anderes Betriebssystem/CPU ohne Neustart oder Wechsel des Computers.

Warum Linux zu Windows und nicht in der anderen Richtung?

Der Hauptgrund dafür ist, daß die Erzeugung von Unix binaries auf einer fremden Plattform (ein anderes Unix oder sogar Linux eingeschlossen) komplizierter ist. Statisches linking ist bereits kompliziert, let alone shared.

Sie würden die verwendeten Bibliotheken der Zielplattformen benötigen (gtk, glib,libc etc), und eine Menge zusätzlicher Konfigurierung für ld. (library paths, dynlinker path etc)

This has been partially done (for the static case), but it is hard since it needs manual postediting of linker files and linker commandline, and a deep understanding about what makes Unix binaries tick.

Ich möchte mehr Informationen über die Erstellung von Freepascal. Wo sind sie?

Eine allgemeine FAQ im PDF-Format über die Erstellung und Konfigurierung von FPC ist: http://www.stack.nl/~marcov/buildfaq.pdf.