Difference between revisions of "objectivepascal"

From Lazarus wiki
Jump to navigationJump to search
Line 1: Line 1:
 +
== Version References ==
 +
 +
This article makes reference to various versions (in scripts and commands) that may not be the most current. Please verify they are correct on your system before trying any of the commands.
 +
 +
* 2.4.2 - The base install of FPC (used for bootstrapping the installation of the latest version)
 +
* 2.5.1 - The latest version of FPC used for compiling Objective Pascal (Cocoa and iOS)
 +
* iPhoneOS4.2.sdk - The latest iOS SDK which is compatible with the translated headers.
 +
 
== Downloading Sources ==
 
== Downloading Sources ==
  
Line 41: Line 49:
 
== Building the compiler for iOS development ==
 
== Building the compiler for iOS development ==
  
Follow the steps below to install the ARM compiler and 386 compiler for iOS simulator. The commands below utilize the standard location of <tt>/Developer/ObjectivePascal/fpc</tt> which contains all FPC sources related to Objective Pascal development.
+
Follow the steps below to install the ARM compiler and 386 compiler for iOS simulator. In the examples below the ''iPhoneOS4.2.sdk'' SDK is used but you should change this to the SDK version which you installed from Xcode.
  
 
1) Download the latest version of FPC and Xcode developer tools (with iOS SDK) then install. Please note you must start with a standard (unchanged) installation of Xcode developer tools and iOS SDK.
 
1) Download the latest version of FPC and Xcode developer tools (with iOS SDK) then install. Please note you must start with a standard (unchanged) installation of Xcode developer tools and iOS SDK.
Line 54: Line 62:
 
3) Build the ARM cross-compiler.
 
3) Build the ARM cross-compiler.
  
* In the examples below the ''iPhoneOS4.2.sdk'' SDK is used but you should change this to the SDK version which you installed from Xcode.
 
 
* If you are using Xcode 3.2.6+ or Xcode 4+, currently you first have to apply a patch to the FPC sources as explained at http://bugs.freepascal.org/view.php?id=19196  
 
* If you are using Xcode 3.2.6+ or Xcode 4+, currently you first have to apply a patch to the FPC sources as explained at http://bugs.freepascal.org/view.php?id=19196  
 
* copy <tt>/Developer/FreePascalCompiler/2.4.2/Source/rtl/darwin/arm/sig_cpu.inc</tt> to <tt>/Developer/ObjectivePascal/fpc/rtl/darwin/arm</tt> (that file was generated when you installed the FPC iPhone SDK integration kit)
 
* copy <tt>/Developer/FreePascalCompiler/2.4.2/Source/rtl/darwin/arm/sig_cpu.inc</tt> to <tt>/Developer/ObjectivePascal/fpc/rtl/darwin/arm</tt> (that file was generated when you installed the FPC iPhone SDK integration kit)
Line 64: Line 71:
 
  sudo ln -sf ../lib/fpc/2.5.1/ppcrossarm /usr/local/bin/ppcarm
 
  sudo ln -sf ../lib/fpc/2.5.1/ppcrossarm /usr/local/bin/ppcarm
  
4) Build the 386 compiler for iOS Simulator.
+
4) Build the Intel compiler for iOS Simulator.
  
 
  cd /Developer/ObjectivePascal/fpc
 
  cd /Developer/ObjectivePascal/fpc

Revision as of 07:54, 23 April 2011

Version References

This article makes reference to various versions (in scripts and commands) that may not be the most current. Please verify they are correct on your system before trying any of the commands.

  • 2.4.2 - The base install of FPC (used for bootstrapping the installation of the latest version)
  • 2.5.1 - The latest version of FPC used for compiling Objective Pascal (Cocoa and iOS)
  • iPhoneOS4.2.sdk - The latest iOS SDK which is compatible with the translated headers.

Downloading Sources

Before building any compilers you must download the FPC sources from SVN. This page references the standard location of /Developer/ObjectivePascal/fpc for all the FPC sources and you may need to create the /Developer/ObjectivePascal directory before going any further.

To check out the FPC sources for the first time use the command:

svn co http://svn.freepascal.org/svn/fpc/trunk /Developer/ObjectivePascal/fpc

To update the FPC sources from a previous download use the command:

svn up http://svn.freepascal.org/svn/fpc/trunk /Developer/ObjectivePascal/fpc

Building the compiler for Cocoa development

1) Download the latest version of FPC and Xcode developer tools then install.

1) Download the latest version of the sources (see #Downloading Sources)

2) Build the Intel compiler to /usr/local/lib/fpc/2.5.1/ppc386

cd /Developer/ObjectivePascal/fpc
sudo make distclean -j 3
sudo make FPC=/usr/local/lib/fpc/2.4.2/ppc386 OPT="-ap" distclean all -j 2
sudo make FPC=`pwd`/compiler/ppc386 install

3) Build the PPC cross-compiler to /usr/local/lib/fpc/2.5.1/ppcppc. If you don't wish to build universal binaries or PPC-only binaries you can skip this step.

cd /Developer/ObjectivePascal/fpc
sudo make distclean -j 3
sudo make FPC=/usr/local/lib/fpc/2.4.2/ppc386 OPT="-ap" distclean CPU_TARGET=powerpc all -j 2
sudo make FPC=`pwd`/compiler/ppcppc CROSSINSTALL=1 install
sudo mv /usr/local/lib/fpc/2.5.1/ppcrossppc /usr/local/lib/fpc/2.5.1/ppcppc

Cocoa Headers

The most recent version of the translated Cocoa headers (which are guaranteed to compile with that version) are location in the FPC distribution at /Developer/ObjectivePascal/fpc/packages/cocoaint/src. If you need newer headers you will need to parse them manually using the framework parser located at /Developer/ObjectivePascal/fpc/packages/cocoaint/utils/parser.php.

Building the compiler for iOS development

Follow the steps below to install the ARM compiler and 386 compiler for iOS simulator. In the examples below the iPhoneOS4.2.sdk SDK is used but you should change this to the SDK version which you installed from Xcode.

1) Download the latest version of FPC and Xcode developer tools (with iOS SDK) then install. Please note you must start with a standard (unchanged) installation of Xcode developer tools and iOS SDK.

If you installed Xcode into another location than the default location /Developer you will need to change the paths below and in any other scripts you may run. Make sure if you installed into another location the path does not contain spaces.

2) Download the latest version of the sources (see #Downloading Sources)

3) Build the ARM cross-compiler.

  • If you are using Xcode 3.2.6+ or Xcode 4+, currently you first have to apply a patch to the FPC sources as explained at http://bugs.freepascal.org/view.php?id=19196
  • copy /Developer/FreePascalCompiler/2.4.2/Source/rtl/darwin/arm/sig_cpu.inc to /Developer/ObjectivePascal/fpc/rtl/darwin/arm (that file was generated when you installed the FPC iPhone SDK integration kit)
cd /Developer/ObjectivePascal/fpc
export IPHONEPLATFORMBASEDIR=/Developer/Platforms/iPhoneOS.platform/Developer
make FPC=/usr/local/lib/fpc/2.4.2/ppc386 CPU_TARGET=arm CROSSOPT="-FD${IPHONEPLATFORMBASEDIR}/usr/bin -XR${IPHONEPLATFORMBASEDIR}/SDKs/iPhoneOS4.2.sdk/ -ap -Cfvfpv2" all
sudo make FPC=`pwd`/compiler/ppcrossarm OPT="-ap" CPU_TARGET=arm CROSSOPT="-FD${IPHONEPLATFORMBASEDIR}/usr/bin -XR${IPHONEPLATFORMBASEDIR}/SDKs/iPhoneOS4.2.sdk/ -ap" install CROSSINSTALL=1
sudo ln -sf ../lib/fpc/2.5.1/ppcrossarm /usr/local/bin/ppcarm

4) Build the Intel compiler for iOS Simulator.

cd /Developer/ObjectivePascal/fpc
make FPC=/usr/local/lib/fpc/2.4.2/ppc386 OS_TARGET=iphonesim all
sudo make FPC=/usr/local/lib/fpc/2.4.2/ppc386 OS_TARGET=iphonesim install CROSSINSTALL=1

iOS Headers

The iOS headers must be manually generated using a script as they can not be legally distributed in translated Pascal form. The SDK used to parse the sources may not be the latest version of the SDK you installed from Xcode. Check that you have the SDK version used in the script make-ios-headers.sh before trying this step.

cd /Developer/ObjectivePascal/fpc/packages/cocoaint/utils
./make-ios-headers.sh

The headers will be parsed and saved into /Developer/ObjectivePascal/fpc/packages/cocoaint/utils/uikit-skel/src.

Compiling iOS Sources

These are example commands you can use to compile iOS programs from the command line. Change the path of the iOS SDK to the version which you generated the headers for.

  • Example command for iOS simulator
/usr/local/lib/fpc/2.5.1/ppcross386 -XX -Tiphonesim -Fu/Developer/ObjectivePascal/fpc/packages/cocoaint/utils/uikit-skel/src -XR/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk program.pas
  • Example command for iOS device
/usr/local/lib/fpc/2.5.1/ppcrossarm -XX -Cfvfpv2 -Fu/Developer/ObjectivePascal/fpc/packages/cocoaint/utils/uikit-skel/src -FD/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin -XR/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.2.sdk program.pas