Lazarus

Programming => LCL => Topic started by: mohsenti on October 27, 2018, 02:10:46 pm

Title: Lazarus Cocoa build failed in Mac OS Mojave 10.14
Post by: mohsenti on October 27, 2018, 02:10:46 pm
Hi
I'm a new MacOS user and I have compile FPC and Lazarus in MacOS 10.14.
FPC x86_64 and cross compile i386 built successful but Lazarus building with cocoa platform failed with below errors
Code: Pascal  [Select][+][-]
  1. cocoaprivate.pas(189,14) Error: There is no method in an ancestor class to be overridden: "acceptsFirstResponder:Boolean;"
  2. cocoaprivate.pas(195,14) Error: There is no method in an ancestor class to be overridden: "acceptsFirstMouse(NSEvent):Boolean;"
  3. cocoaprivate.pas(189,14) Error: Objective-C messages require their Objective-C selector name to be specified using the "message" directive.
  4. cocoaprivate.pas(195,14) Error: Mismatch between number of declared parameters and number of colons in message string.
  5. cocoaprivate.pas(254,14) Error: There is no method in an ancestor class to be overridden: "acceptsFirstResponder:Boolean;"
  6. cocoaprivate.pas(254,14) Error: Objective-C messages require their Objective-C selector name to be specified using the "message" directive.
  7. cocoaprivate.pas(273,14) Error: There is no method in an ancestor class to be overridden: "acceptsFirstResponder:Boolean;"
  8. cocoaprivate.pas(280,14) Error: There is no method in an ancestor class to be overridden: "acceptsFirstMouse(NSEvent):Boolean;"
  9. cocoaprivate.pas(273,14) Error: Objective-C messages require their Objective-C selector name to be specified using the "message" directive.
  10. cocoaprivate.pas(280,14) Error: Mismatch between number of declared parameters and number of colons in message string.
  11. cocoaprivate.pas(314,14) Error: There is no method in an ancestor class to be overridden: "acceptsFirstResponder:Boolean;"
  12. cocoaprivate.pas(325,14) Error: There is no method in an ancestor class to be overridden: "acceptsFirstMouse(NSEvent):Boolean;"
  13. cocoaprivate.pas(314,14) Error: Objective-C messages require their Objective-C selector name to be specified using the "message" directive.
  14. cocoaprivate.pas(325,14) Error: Mismatch between number of declared parameters and number of colons in message string.
  15. cocoaprivate.pas(366,1) Fatal: There were 14 errors compiling module, stopping
  16. Fatal: Compilation aborted
  17.  

And I built lazarus with
Quote
make LCL_PLATFORM="cocoa"
command.

Anyone have any solution for this problem ?
Title: Re: Lazarus Cocoa build failed in Mac OS Mojave 10.14
Post by: ChrisR on October 27, 2018, 04:18:51 pm
I have 10.13, not 10.14, but I just built the latest SVN using the following commands:

$ svn up
Updating '.':
U    lcl/interfaces/cocoa/cocoawinapi.inc
U    lcl/interfaces/cocoa/cocoagdiobjects.pas
U    lcl/interfaces/cocoa/cocoautils.pas
Updated to revision 59373.
$make LCL_PLATFORM=cocoa CPU_TARGET=x86_64 clean bigide
...
$startlazarus
Title: Re: Lazarus Cocoa build failed in Mac OS Mojave 10.14
Post by: mohsenti on October 27, 2018, 04:33:30 pm
Thank you ChrisR,
I test your solution but it's not work in MacOS 10.14.
Title: Re: Lazarus Cocoa build failed in Mac OS Mojave 10.14
Post by: skalogryz on October 27, 2018, 05:27:46 pm
http://wiki.freepascal.org/Cocoa_Internals#Recompilation
Title: Re: Lazarus Cocoa build failed in Mac OS Mojave 10.14
Post by: mohsenti on October 28, 2018, 10:58:15 am
thank you skalogryz.

I think after Dark mode theme added  to MacOS, they change cocoa api and this changes break LCL cocoa platform.
Title: Re: Lazarus Cocoa build failed in Mac OS Mojave 10.14
Post by: CCRDude on October 31, 2018, 01:14:00 pm
I've got the same problem; trunk both fpc & Lazarus, cross-compiling from Windows.

The link by @skalogryz is not helpful here; the error appears in CocoaPrivate.pas, which is part of the LCL; but it refers to ancestors in NSControl -> NSView -> NSResponder, which are defined in FPC package cocoaint.

Digging further, the return type of these two functions is bad. In FPC, it's BOOL = boolean8; in LCL, it's Boolean.

So break is totally within the FPC/Lazarus world, not Dark Mode / Mojave related.
Title: Re: Lazarus Cocoa build failed in Mac OS Mojave 10.14
Post by: Thaddy on October 31, 2018, 01:22:05 pm
There are currently more problems with 32 bit targets due to FPC rev 39986.
Title: Re: Lazarus Cocoa build failed in Mac OS Mojave 10.14
Post by: CCRDude on October 31, 2018, 02:02:34 pm
Good that I haven't tried 32 bit yet :D

For the issue of the OP, I have tried to replace boolean with boolean8 in the LCL units. It will compile after replacing quite a bunch, but I guess that was a bit too simple. My compiled application does not accept keyboard input into an InputQuery, which I could imagine - based on the affected methods - might be a result of this.
Title: Re: Lazarus Cocoa build failed in Mac OS Mojave 10.14
Post by: skalogryz on October 31, 2018, 02:39:47 pm
.. trunk .. fpc
...
In FPC, it's BOOL = boolean8; in LCL, it's Boolean.
:'(  :'(  :'(
source level compatibility is broken.

is it possible to use 3.0.4 ? (3.0.4a?)
Title: Re: Lazarus Cocoa build failed in Mac OS Mojave 10.14
Post by: CCRDude on November 02, 2018, 09:49:19 am
Just wanted to add that my keyboard issues were coming from the compiled file running in terminal. Once wrapped into a .app, everything works fine. Which means the workaround mentioned is working on x86_64-darwin (not tested other modes).
Title: Re: Lazarus Cocoa build failed in Mac OS Mojave 10.14
Post by: MISV on November 27, 2018, 01:33:46 am
I have now reported the cocoaprivate issue here: https://bugs.freepascal.org/view.php?id=34609 (https://bugs.freepascal.org/view.php?id=34609)

Hopefully someone will roll back the changes or fix this - but at least now the problem has been reported :(
Title: Re: Lazarus Cocoa build failed in Mac OS Mojave 10.14
Post by: skalogryz on December 05, 2018, 04:58:09 pm
Could anyone test r59725, please?
The fix needs to go with the Lazarus release.
It's quite important for LCL to compile with both 3.0.4 (the latest stable FPC) release as well as with FPC trunk (as the most proper compiler version for mac)
Title: Re: Lazarus Cocoa build failed in Mac OS Mojave 10.14
Post by: Josh on December 05, 2018, 07:35:07 pm
Just tried install of cocoa 64 bit on trunk lap and fpc.
but get error
Code: [Select]
/Users/josh/lazarus_trunk_cocoa/lazarus/lcl/interfaces/./cocoa/cocoatextedits.pas(585,8) Warning: (4040) Class types "NSTextDelegateProtocol" and "NSObject" are not related
/Users/josh/lazarus_trunk_cocoa/lazarus/lcl/interfaces/./cocoa/cocoatextedits.pas(592,40) Warning: (4040) Class types "NSTextDelegateProtocol" and "NSObject" are not related
(3104) Compiling ./cocoa/cocoawindows.pas
/Users/josh/lazarus_trunk_cocoa/lazarus/lcl/interfaces/./cocoa/cocoawindows.pas(403,41) Error: (3069) Call by var for arg no. 3 has to match exactly: Got "Boolean8" expected "Boolean"
cocoawindows.pas(1339) Fatal: (10026) There were 1 errors compiling module, stopping
Fatal: (1018) Compilation aborted
cocoawindows.pas(1339) Fatal: (10026) There were 1 errors compiling module, stopping
Fatal: (1018) Compilation aborted
Error: /Users/josh/lazarus_trunk_cocoa/fpc/bin/x86_64-darwin/ppcx64 returned an error exitcode
Error: (lazarus) Compile package LCL 2.1: stopped with exit code 256
Error: (lazarus) [TLazPackageGraph.CompileRequiredPackages] "Exit code 256"
Error: (lazarus) Building IDE: Compile AutoInstall Packages failed.
make: *** [useride] Error 2
fpcupdeluxe: ERROR: LazarusNativeInstaller (BuildModuleCustom: UserIDE): make returned error code #512
fpcupdeluxe: ERROR: LazarusNativeInstaller (BuildModuleCustom: UserIDE): make returned error code #512


ERROR: Fpcupdeluxe fatal error !

Does that help.

I will try a fresh install
Title: Re: Lazarus Cocoa build failed in Mac OS Mojave 10.14
Post by: CCRDude on December 05, 2018, 07:41:02 pm
I was trying fpcupdeluxe with trunk/trunk as well as fixes3.2/trunk on macOS High Sierra today and got:
Quote
/Developer/lazarus/lazarus/lcl/interfaces/./cocoa/cocoawindows.pas(403,41) Error: (3069) Call by var for arg no. 3 has to match exactly: Got "Boolean8" expected "Boolean"
cocoawindows.pas(1339) Fatal: (10026) There were 1 errors compiling module, stopping

Same on Windows 10 cross-compiling for Darwin/Cocoa with trunk/trunk.
Title: Re: Lazarus Cocoa build failed in Mac OS Mojave 10.14
Post by: CCRDude on December 05, 2018, 07:45:30 pm
This does not seem trivial to fix, since LclObjCBoolean is defined in CocoaPrivate, but required in the interface of CocoaUtils, causing a circular unit reference.

Furthermore, Cocoa_Extra already has an 8 bit ObjCBool. Two different boolean types in two different units with different prefixes do not look like a good idea.
Title: Re: Lazarus Cocoa build failed in Mac OS Mojave 10.14
Post by: skalogryz on December 05, 2018, 08:00:58 pm
This does not seem trivial to fix, since LclObjCBoolean is defined in CocoaPrivate, but required in the interface of CocoaUtils, causing a circular unit reference.
how come? custom changes?

Furthermore, Cocoa_Extra already has an 8 bit ObjCBool. Two different boolean types in two different units with different prefixes do not look like a good idea.
ObjCBool is hidden by {$ifdef BOOLFIX}
cocoadefines.inc needs to be updated to undefine BOOLFIX for any FPC version past 3.0.4.
For 3.0.4 ObjCBool is not a duplication, but rather
LCLObjCBoolean - has intent to be cross FPC version compatible
ObjCBool - has intent to be binary correct for ObjC call for fpc 3.0.4
Ultimately both are present to address the same problem, but in different spotss.
Title: Re: Lazarus Cocoa build failed in Mac OS Mojave 10.14
Post by: CCRDude on December 05, 2018, 08:14:50 pm
No custom changes, fresh checkouts.

I simply saw that NSResponderHotKeys is responsible for the errors seen by josh and myself, and that one is in CocoaUtils. I saw that LCLObjCBoolean is defined in CocoaPrivate, but I cannot add CocoaPrivate to the uses part of CocoaUtils, since CocoaPrivate already uses CocoaUtils.

0. I gave it a few more tries, and moved the LCLObjCBoolean definition to Cocoa_Extra. That avoids the circular reference, and allows to compile, with the following problems coming up:
1. In CocoaDatePicker, there's still TCocoaDatePicker.acceptsFirstResponder with the wrong type in interface and implementation.
2. In CocoaWSMenus, TCocoaMenuItem, you changed boolean to LCLObjCBoolean only in the interface, not the implementation.
3. In cocoaprinters_h.inc, TCocoaPrinterView, the update from boolean to LCLObjCBoolean was still missing for knowsPageRange and isFlipped.

With those changes, I was able to cross-compile to Darwin/Cocoa and the output works fine on High Sierra.
Title: Re: Lazarus Cocoa build failed in Mac OS Mojave 10.14
Post by: skalogryz on December 05, 2018, 08:17:58 pm
I simply saw that NSResponderHotKeys is responsible for the errors seen by josh and myself, and that one is in CocoaUtils. I saw that LCLObjCBoolean is defined in CocoaPrivate, but I cannot add CocoaPrivate to the uses part of CocoaUtils, since CocoaPrivate already uses CocoaUtils.
NSResponderHotKeys is a procedure. It doesn't need LCLObjCBoolean

Code: Diff  [Select][+][-]
  1. Index: cocoawindows.pas
  2. ===================================================================
  3. --- cocoawindows.pas    (revision 59729)
  4. +++ cocoawindows.pas    (working copy)
  5. @@ -389,6 +389,7 @@
  6.    resp : NSResponder;
  7.    wn   : NSWindow;
  8.    view : NSTextView;
  9. +  r    : Boolean;
  10.  begin
  11.    Result := false;
  12.    // only respond to key, if focused
  13. @@ -400,7 +401,8 @@
  14.  
  15.    if (not resp.lclIsEnabled) then Exit;
  16.  
  17. -  NSResponderHotKeys(self, event, Result, resp);
  18. +  NSResponderHotKeys(self, event, r, resp);
  19. +  Result := r;
  20.    if not Result then
  21.      Result:=inherited performKeyEquivalent(event);
  22.  end;

Please provide a patch for points 1 through 3 and I'll apply them tonight!
Title: Re: Lazarus Cocoa build failed in Mac OS Mojave 10.14
Post by: CCRDude on December 05, 2018, 08:21:41 pm
NSResponderHotKeys is a procedure that takes, as its third parameter, a "var handled: boolean".

But TCocoaWindowContent.performKeyEquivalent passes it's Result, which is a LCLObjCBoolean, as third parameter to NSResponderHotKeys.

I felt it safer to adjust the var parameter of the procedure, than to typecast the boolean forth and back.
Title: Re: Lazarus Cocoa build failed in Mac OS Mojave 10.14
Post by: CCRDude on December 05, 2018, 08:23:55 pm
I now see your edit, but don't understand it. Since the problem is that NSResponderHotKeys expects a boolean, what help would it do to pass a variable "r" of the same type as the non-functioning result, LCLObjCBoolean? And what exactly means "Result := rsbool", should this be "Result := r", with an "r: boolean" instead of an "r: LCLOBjCBoolean"?

Whether this is solved by the helper var, or changing the parameter type, the other three issues reported by me above are independent of this.
Title: Re: Lazarus Cocoa build failed in Mac OS Mojave 10.14
Post by: skalogryz on December 05, 2018, 08:25:42 pm
should this be "Result := r", with an "r: boolean" instead of an "r: LCLOBjCBoolean"?
yes it should, i updated the patch

Whether this is solved by the helper var, or changing the parameter type, the other three issues reported by me above are independent of this.
These are two different approaches, because change in parameter type requires to move the type declaration.

Long term: NSResponderHotKeys  needs to be moved to cocoawindows.pas
Title: Re: Lazarus Cocoa build failed in Mac OS Mojave 10.14
Post by: Josh on December 05, 2018, 10:36:33 pm
Just this minute finish attempt at a fresh install of cocoa 64, and it fails with same error as before.

Unfortunately I have not been able to compile anything on Cocoa for the past 2 months natively on High Sierra, and now I can't cross compile to cocoa 64 from carbon 32.

Would be a good x-mas present to get the Cocoa 64 working again; just to see the improvements over the past  2 months.
Title: Re: Lazarus Cocoa build failed in Mac OS Mojave 10.14
Post by: CCRDude on December 11, 2018, 11:40:10 am
Just another (positive this time) update: today I ran fpcupdeluxe with trunk/trunk and Darwin/x86_64 on my Mac and it produces a Lazarus that produces Cocoa apps out of the box. No more boolean type issues.

Many thanks skalogryz for all your hard work on improving the Cocoa widgetset. Much appreciated!
TinyPortal © 2005-2018