Difference between revisions of "Carbon Interface"

From Lazarus wiki
Jump to navigationJump to search
(Minor updates and wordsmithing.)
Line 3: Line 3:
 
== What you need ==
 
== What you need ==
  
The Carbon widgetset is in an early stage of development. A fully functional Lazarus IDE on Mac OS X is strongly recommended. For instructions see [[Installing Lazarus on MacOS X|Installing Lazarus on Mac OS X]].
+
The Carbon widgetset is in an early stage of development. A fully functional Lazarus IDE (compiled against GTK widgetset) on Mac OS X is strongly recommended. For instructions see [[Installing Lazarus on MacOS X|Installing Lazarus on Mac OS X]].
  
== Getting a carbonproof Lazarus ==
+
== Getting a "carbonproof" Lazarus ==
 +
 
 +
Note: If you installed a Lazarus snapshot, you can skip this section and the next since the snapshot includes both the Carbon widgetset source and compiled units for the Carbon widgetset.
  
 
*Install SVN for Mac OS X: A good package is provided by [http://www.codingmonkeys.de/mbo/ Martin Ott].
 
*Install SVN for Mac OS X: A good package is provided by [http://www.codingmonkeys.de/mbo/ Martin Ott].
Line 12: Line 14:
 
*Start Lazarus. The IDE will start with a new project with an empty form. Save this project under a name of your choice. In the following examples we assume this to be /Users/<yourUsername>/pascal/test/project1.lpi
 
*Start Lazarus. The IDE will start with a new project with an empty form. Save this project under a name of your choice. In the following examples we assume this to be /Users/<yourUsername>/pascal/test/project1.lpi
  
== Compiling the Carbon Interface ==
+
== Compiling the Carbon interface ==
  
 
We now assume your Lazarus directory is located at /Users/<yourUsername>/pascal/lazarus/
 
We now assume your Lazarus directory is located at /Users/<yourUsername>/pascal/lazarus/
Line 28: Line 30:
 
*Tools>Build Lazarus -- This will compile the Carbon Interface and put the .ppu files into /Users/<yourUsername>/pascal/lazarus/lcl/units/powerpc-darwin and /Users/<yourUsername>/pascal/lazarus/lcl/units/powerpc-darwin/carbon
 
*Tools>Build Lazarus -- This will compile the Carbon Interface and put the .ppu files into /Users/<yourUsername>/pascal/lazarus/lcl/units/powerpc-darwin and /Users/<yourUsername>/pascal/lazarus/lcl/units/powerpc-darwin/carbon
  
== Your first native Carbon App ==
+
== Your first native Carbon app ==
  
 
=== Compiler Options ===
 
=== Compiler Options ===
Line 46: Line 48:
 
You should now be able to compile the project without errors. It will create an executable ''project1'', but you can not focus it. That's because Mac OS X expects some hidden resource files.
 
You should now be able to compile the project without errors. It will create an executable ''project1'', but you can not focus it. That's because Mac OS X expects some hidden resource files.
  
== Creating the Apple Resource files ==
+
== Creating the Apple resource files ==
  
 
There is a tool to create these files.  
 
There is a tool to create these files.  
Line 59: Line 61:
 
</pre>
 
</pre>
 
Now you can start the program via its Finder icon or in the native Mac OS Terminal via ./project1.app/Contents/MacOS/project1
 
Now you can start the program via its Finder icon or in the native Mac OS Terminal via ./project1.app/Contents/MacOS/project1
 +
 +
Tip: There is also a script that creates this app bundle at [[OS_X_Programming_Tips]].
  
 
== Carbon interface internals ==
 
== Carbon interface internals ==
  
If you want to help improving the carbon interface, see here
+
If you want to help improving the Carbon interface, see here:
  
 
[[Carbon interface internals]]
 
[[Carbon interface internals]]

Revision as of 21:38, 25 February 2007

Deutsch (de) English (en) 日本語 (ja)

macOSlogo.png

This article applies to macOS only.

See also: Multiplatform Programming Guide


What you need

The Carbon widgetset is in an early stage of development. A fully functional Lazarus IDE (compiled against GTK widgetset) on Mac OS X is strongly recommended. For instructions see Installing Lazarus on Mac OS X.

Getting a "carbonproof" Lazarus

Note: If you installed a Lazarus snapshot, you can skip this section and the next since the snapshot includes both the Carbon widgetset source and compiled units for the Carbon widgetset.

  • Start Lazarus. The IDE will start with a new project with an empty form. Save this project under a name of your choice. In the following examples we assume this to be /Users/<yourUsername>/pascal/test/project1.lpi

Compiling the Carbon interface

We now assume your Lazarus directory is located at /Users/<yourUsername>/pascal/lazarus/

  • Start Lazarus.
  • Set Environment>Environment Options>Files>Lazarus Directory to /Users/<yourUsername>/pascal/lazarus/
  • Set Tools>Configure "Build Lazarus"> to

BuildLazarusOptionsCarbonIntf.png

and add this to your 'Options':

-k-framework -kcarbon

This will prevent unresolved symbols (Carbon-symbols like _ActivateWindow) while linking lazarus.

  • Tools>Build Lazarus -- This will compile the Carbon Interface and put the .ppu files into /Users/<yourUsername>/pascal/lazarus/lcl/units/powerpc-darwin and /Users/<yourUsername>/pascal/lazarus/lcl/units/powerpc-darwin/carbon

Your first native Carbon app

Compiler Options

Set Project > Compiler Options > Paths > LCL Widget Type to carbon

Set Project > Compiler Options > Linkink > Options Check Pass Options to the Linker

and type in the edit field:

-framework carbon

File:CarbonLinkerOptions.png

You should now be able to compile the project without errors. It will create an executable project1, but you can not focus it. That's because Mac OS X expects some hidden resource files.

Creating the Apple resource files

There is a tool to create these files.

Open /Users/<yourUserName>/pascal/lazarus/components/macfiles/examples/createmacapplication.lpi in the IDE. Compile.

Open a Terminal of your choice. Type:

cd /Users/<yourUserName>/pascal/project1/
/Users/<yourUserName>/pascal/lazarus/components/macfiles/examples/createmacapplication project1
ln -s ../../../project1 project1.app/Contents/MacOS/project1

Now you can start the program via its Finder icon or in the native Mac OS Terminal via ./project1.app/Contents/MacOS/project1

Tip: There is also a script that creates this app bundle at OS_X_Programming_Tips.

Carbon interface internals

If you want to help improving the Carbon interface, see here:

Carbon interface internals