Recent

Author Topic: 64 bit lcl port to cocoa/quartz/etc.  (Read 6966 times)

lks

  • New Member
  • *
  • Posts: 12
64 bit lcl port to cocoa/quartz/etc.
« on: December 04, 2012, 01:27:32 am »
Is anybody currently working on this?  Just trying to figure out how realistic it is to port an application that runs on win64 and i386/darwin and have it run on the Mac in 64 bit mode.

Phil

  • Hero Member
  • *****
  • Posts: 2750
Re: 64 bit lcl port to cocoa/quartz/etc.
« Reply #1 on: December 04, 2012, 01:33:29 am »
Is anybody currently working on this?  Just trying to figure out how realistic it is to port an application that runs on win64 and i386/darwin and have it run on the Mac in 64 bit mode.

Lazarus LCL for Carbon is limited to 32-bits. If your app's UI is sufficiently separated from the non-UI code, you can port it using Cocoa directly, designing your Cocoa UI in Xcode. See this series of tutorials:

http://dl.dropbox.com/u/28343282/ObjP/index.html

Thanks.

-Phil

lks

  • New Member
  • *
  • Posts: 12
Re: 64 bit lcl port to cocoa/quartz/etc.
« Reply #2 on: December 04, 2012, 01:43:02 am »
I haven't read that document yet, but does this use the code that appears in lcl/interfaces/cocoa?

Phil

  • Hero Member
  • *****
  • Posts: 2750
Re: 64 bit lcl port to cocoa/quartz/etc.
« Reply #3 on: December 04, 2012, 01:49:27 am »
I haven't read that document yet, but does this use the code that appears in lcl/interfaces/cocoa?

No, you use FPC's Objective Pascal dialect to work directly with the Cocoa Objective C controls.

This allows you to use everything available in Cocoa, including powerful controls like Webview and NSTableView.

Your non-UI code can be used unchanged.

Thanks.

-Phil

lks

  • New Member
  • *
  • Posts: 12
Re: 64 bit lcl port to cocoa/quartz/etc.
« Reply #4 on: December 04, 2012, 01:57:30 am »
For the most part, the GUI part of my code directly interfaces with the platform's native graphics library (on Windows:  GDI+, on Mac 32:  Carbon), but there are places where the code depends on LCL (TThread, TForm, etc.).

So, I guess my question is, is anybody working on any parts of the LCL for 64 bit Mac?

Phil

  • Hero Member
  • *****
  • Posts: 2750
Re: 64 bit lcl port to cocoa/quartz/etc.
« Reply #5 on: December 04, 2012, 02:12:16 am »
For the most part, the GUI part of my code directly interfaces with the platform's native graphics library (on Windows:  GDI+, on Mac 32:  Carbon), but there are places where the code depends on LCL (TThread, TForm, etc.).

So, I guess my question is, is anybody working on any parts of the LCL for 64 bit Mac?

There's been some work on LCL Cocoa over the years, but looking at its status in SVN it doesn't look like anyone is working on it.

Note that you won't be able to use your Carbon code in a 64-bit app. You can use OpenGL and Quartz, though.

Also, you won't be able to create document-based apps with LCL for Mac - most Mac apps are document-based, but LCL apps are single-document, eg, Laz IDE itself can only open one project at a time. Contrast with Mac's IDEs, Xcode and Dashcode, which can both open multiple projects simultaneously - this is the hallmark of the document-based approach that Apple's encourages and that most apps adopt.

Note that classes such as TThread are part of FPC RTL, not LCL, and so are not limited to LCL-based apps.

Thanks.

-Phil

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3541
Re: 64 bit lcl port to cocoa/quartz/etc.
« Reply #6 on: December 13, 2012, 12:50:29 pm »
LCL-CustomDrawn can be utilized to create 64-bits Mac apps as it has a Cocoa backend.

Also, Paul is working on LCL-Cocoa: http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/lcl/interfaces/cocoa/?root=lazarus&view=log

lks

  • New Member
  • *
  • Posts: 12
Re: 64 bit lcl port to cocoa/quartz/etc.
« Reply #7 on: December 15, 2012, 07:03:12 am »
I will look into both LCL-CustomDrawn and LCL-Cocoa. 

It would of course be great if LCL were ported to Cocoa, as Carbon is no longer the preferred toolkit on Macs.  So I thought I would see how far along the port was by trying to rebuild lazarus with cocoa (I wasn't expecting this to work, but I just wanted to see what would happen).

Unfortunately when I tried to rebuild Lazarus with widget set cocoa(alpha) I get errors like this when compiling cocoagdiobjects.pas:

Code: [Select]
cocoagdiobjects.pas(837,60) Error: Incompatible type for arg no. 1: Got "CGIMAGE.CGImageRef", expected "MACOSALL.CGImageRef"

In MacOSAll it includes the file CGImage with a conditional define that turns off the unit declaration for CGImage, but somehow in another file within fpc CGImage is included directly.

I am using the most recent fpc and lazarus svn trunks.

Not quite sure the best way to cure this problem.  Any ideas?

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3541
Re: 64 bit lcl port to cocoa/quartz/etc.
« Reply #8 on: December 15, 2012, 10:09:18 am »
Try FPC 2.6

nhatdung

  • New Member
  • *
  • Posts: 34
Re: 64 bit lcl port to cocoa/quartz/etc.
« Reply #9 on: January 16, 2013, 02:36:17 am »
Is anybody currently working on this?  Just trying to figure out how realistic it is to port an application that runs on win64 and i386/darwin and have it run on the Mac in 64 bit mode.

Lazarus LCL for Carbon is limited to 32-bits. If your app's UI is sufficiently separated from the non-UI code, you can port it using Cocoa directly, designing your Cocoa UI in Xcode. See this series of tutorials:

http://dl.dropbox.com/u/28343282/ObjP/index.html

Thanks.

-Phil

can i use this in lastest xcode ?

lks

  • New Member
  • *
  • Posts: 12
Re: 64 bit lcl port to cocoa/quartz/etc.
« Reply #10 on: February 23, 2013, 07:13:36 am »
Try FPC 2.6

The last few days I was able to play with this a bit more.

Indeed you were right -- I can compile either cocoa or customdrawn under fpc 2.6.

I was able to compile cocoa (or customdrawn) under fpc 2.7.1 as follows:

- copy fpc/packages/cocoaint/src/CocoaAll.pas and UndefinedTypes.inc into lcl/interfaces/cocoa (or lcl/interfaces/customdrawn),
- modify the copied CocoaAll.pas so it uses MacOSAll and does not use any of the fundamental units directly (the units CF*, CG*, CV*). 
- Finally, modify the package build file for lcl.lpk to include $(FPCSrcDir)/packages/cocoaint/src in both the unit path and the include path.

Of course, compiling the widget set is one thing, but getting an existing carbon application to work with it is something quite different!  But at least I can see how feasible a project this is now.